jasonsalas
IS-IT--Management
Hi everyone,
I've got an interesting problem...is refreshing a page through client-side JavaScript, specifically:
<script language="JavaScript">
// refreshes the current page every 9 seconds
var intervalID;
intervalID = window.setInterval("nextSlide()",9000);
function nextSlide()
{
document.execCommand("Refresh"
}
</script>
...the same functionally as posting a page back? And if so, is ViewState not programmatically controllable? I'm thinking perhaps not, because I'm trying to develop a slide show control that first populates an array, and then stores a single integer value in ViewState and then increment that value so that one element within the array is shown at a time:
//1st page load:
int currentSlide = (int)ViewState["nextSlide"];
arrSlide[0] = // display contents;
ViewState["nextSlide"] = currentSlide + 1;
//2nd page load:
int currentSlide = (int)ViewState["nextSlide"];
arrSlide[1] = // display contents;
ViewState["nextSlide"] = currentSlide + 1;
//nth page load:
int currentSlide = (int)ViewState["nextSlide"];
arrSlide[n] = // display contents;
ViewState["nextSlide"] = currentSlide + 1;
The JavaScript above is written to the client page so that that page reloads automatically, and in theory displays the next slide in the series. But for some reason, when I refresh the page with the JavaScript, I'm always getting the first value of ViewState (being 0), so I never advance past the first slide. This leads me to believe that refreshing the page isn't actually posting back and not persisting data in ViewState. Got any ideas?
I was thinking that if this is the case (not actually posting back), then I'll roll a custom event and use the postback interfaces for controls.
Thanks!
Jas
I've got an interesting problem...is refreshing a page through client-side JavaScript, specifically:
<script language="JavaScript">
// refreshes the current page every 9 seconds
var intervalID;
intervalID = window.setInterval("nextSlide()",9000);
function nextSlide()
{
document.execCommand("Refresh"
}
</script>
...the same functionally as posting a page back? And if so, is ViewState not programmatically controllable? I'm thinking perhaps not, because I'm trying to develop a slide show control that first populates an array, and then stores a single integer value in ViewState and then increment that value so that one element within the array is shown at a time:
//1st page load:
int currentSlide = (int)ViewState["nextSlide"];
arrSlide[0] = // display contents;
ViewState["nextSlide"] = currentSlide + 1;
//2nd page load:
int currentSlide = (int)ViewState["nextSlide"];
arrSlide[1] = // display contents;
ViewState["nextSlide"] = currentSlide + 1;
//nth page load:
int currentSlide = (int)ViewState["nextSlide"];
arrSlide[n] = // display contents;
ViewState["nextSlide"] = currentSlide + 1;
The JavaScript above is written to the client page so that that page reloads automatically, and in theory displays the next slide in the series. But for some reason, when I refresh the page with the JavaScript, I'm always getting the first value of ViewState (being 0), so I never advance past the first slide. This leads me to believe that refreshing the page isn't actually posting back and not persisting data in ViewState. Got any ideas?
I was thinking that if this is the case (not actually posting back), then I'll roll a custom event and use the postback interfaces for controls.
Thanks!
Jas