JavaScript variable from ASP form?
-
Here's my situation. I've got an ASPX page that needs to be refreshed with new content every few seconds, but that amount of time is variable. I'm sending that variable to the page from the server-side application on every refresh. That way, theoretically, the page can automatically refresh when that variable amount of time is elapsed and thereby get a new amount of time to count down. Setting up a JavaScript reload function is easy enough, but I can't find a way to get that ASP variable into the Javascript, as the JavaScript seems to be able to only access HTML form components and not ASP form objects. So, I either need a way to get an ASP variable into the JavaScript, or I need a different client-side script that can actually get that variable from an ASP control and is still capable of causing a PostBack like JavaScript can. Any ideas? Thanks for your help!
-
Here's my situation. I've got an ASPX page that needs to be refreshed with new content every few seconds, but that amount of time is variable. I'm sending that variable to the page from the server-side application on every refresh. That way, theoretically, the page can automatically refresh when that variable amount of time is elapsed and thereby get a new amount of time to count down. Setting up a JavaScript reload function is easy enough, but I can't find a way to get that ASP variable into the Javascript, as the JavaScript seems to be able to only access HTML form components and not ASP form objects. So, I either need a way to get an ASP variable into the JavaScript, or I need a different client-side script that can actually get that variable from an ASP control and is still capable of causing a PostBack like JavaScript can. Any ideas? Thanks for your help!
Hi there. If you're already setting up the javascript function, allow it to accept a parameter. Then from your server-side code, render the appropriate javascript call to start the timer with the parameter hard-coded.