locked
revolving display of data in a database / flash cards RRS feed

  • Question

  • User2074931137 posted

    Can anyone recommend where I should start researching how, using asp.net, I can display data from a property set in a flash card type program where it displays data from a property for a certain amount of time and then data from a second property for a certain amount of time and then moves to the next record and repeats?

    I used javascript successfully to display urls for a certain amount of time and then advance to another url and repeat but the urls were hard coded into the code.  I would like the flash card to get its data to display from a database and revolve through the data in the database.

    Would I use Javascript?  What would this functionality be called for me to look up?

    Thanks in advance.

    Friday, August 7, 2020 12:28 AM

Answers

  • User753101303 posted

    Hi,

    Rather than hardcoding data into the JavaScript code you could "inject" this data (as an array)  inside the JavaScript code. For example :

    var data = @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(yourData));
    

    For example if this an array of string it will be rendered as var data=["a","b","c"]; and then rest of the code could use this array.

    Another option is to use https://docs.microsoft.com/en-us/aspnet/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api especially if what to do next depends on the current response. It allows to send data to the web server "behind the scene" from JavaScript. You can then  get data in response that you can use to update parts of the current page.

    With 800+ posts it seems a bit weird you don't have be exposed yet to that or be explicit about the very first problem in which you are running (not using any database yet ?)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 7, 2020 12:32 PM

All replies

  • User753101303 posted

    Hi,

    Rather than hardcoding data into the JavaScript code you could "inject" this data (as an array)  inside the JavaScript code. For example :

    var data = @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(yourData));
    

    For example if this an array of string it will be rendered as var data=["a","b","c"]; and then rest of the code could use this array.

    Another option is to use https://docs.microsoft.com/en-us/aspnet/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api especially if what to do next depends on the current response. It allows to send data to the web server "behind the scene" from JavaScript. You can then  get data in response that you can use to update parts of the current page.

    With 800+ posts it seems a bit weird you don't have be exposed yet to that or be explicit about the very first problem in which you are running (not using any database yet ?)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 7, 2020 12:32 PM
  • User2074931137 posted

    Thank you PatriceSc -

    I'll start where you suggested.

    I've worked with a number of small, very basic databases locally and on Azure over the years - I am self-taught (which is frustratingly slow) -  My coding needs have been pretty basic to filtering data through views and sorting and searching data.  I was very excited to work with Javasript the first time to revolve through specific urls;  excited about trying to inject data now.

    Thanks again.

    Friday, August 7, 2020 1:20 PM