J
Jason Chan
I have a paging datalist which show a list of thumbnail.
Above the datalist there is a dropdown to jump to different paging.
On Page_load, I bind the datalist according to the current page.
On the same time, I have to generate a dynamic javascript to load the image
in the datalist to an javascript array
So I use Page.RegisterStartupScript to insert the script just before the
closing form tag.
The code works fine for the first page, however when I jump to another page,
from the source code, I found that the JavaScript keep showing the script of
the first page. This make my page doesn't work properly
That is, for example.
page 1 of datalist load 5 images (1.jpg, 2.jpg, 3.jpg, 4.jpg, 5.jpg)
the javascript of the page 1 is dynamic generated and registered
img[0] = "1.jpg";img[1] = "2.jpg";img[2] = "3.jpg";img[3] = "4.jpg";img[4] =
"5.jpg";
when I jump to page 2, it load another 5 images (6.jpg, 7.jpg, 8.jpg, 9.jpg,
10.jpg)
the javascript should look like
img[0] = "6.jpg";img[1] = "7.jpg";img[2] = "8.jpg";img[3] = "9.jpg";img[4] =
"10.jpg";
However, it just keep showing the first script, any idea?
P.S using ASP.NET 2.0
Above the datalist there is a dropdown to jump to different paging.
On Page_load, I bind the datalist according to the current page.
On the same time, I have to generate a dynamic javascript to load the image
in the datalist to an javascript array
So I use Page.RegisterStartupScript to insert the script just before the
closing form tag.
The code works fine for the first page, however when I jump to another page,
from the source code, I found that the JavaScript keep showing the script of
the first page. This make my page doesn't work properly
That is, for example.
page 1 of datalist load 5 images (1.jpg, 2.jpg, 3.jpg, 4.jpg, 5.jpg)
the javascript of the page 1 is dynamic generated and registered
img[0] = "1.jpg";img[1] = "2.jpg";img[2] = "3.jpg";img[3] = "4.jpg";img[4] =
"5.jpg";
when I jump to page 2, it load another 5 images (6.jpg, 7.jpg, 8.jpg, 9.jpg,
10.jpg)
the javascript should look like
img[0] = "6.jpg";img[1] = "7.jpg";img[2] = "8.jpg";img[3] = "9.jpg";img[4] =
"10.jpg";
However, it just keep showing the first script, any idea?
P.S using ASP.NET 2.0