My Purpose:Creating an imagebutton once it is clicked the consumer ought to wait 4 seconds while he is waiting images on the top of the webpage should change automaticly. What I tried so far:
protected void Page_Load(object sender, EventArgs e)
{
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
int counter = 0;
while (counter < 4)
{
counter++;
Image2.ImageUrl = "../images/" + counter + ".jpg";
System.Threading.Thread.Sleep(1000);
}
Response.Redirect("../Home.aspx");
}
I haven't got the same consequences as mentioned earlier. anyone have either solution for solving the problem or a new idea? thnx in advance
Your code makes the web application sleep for 4 seconds, effectively delaying serving the page for 4 seconds. The page is only served after the ImageButton1_Click method is finished.
You should use Javascript to accomplish your purpose.
The problems with your code:
../Home.aspx
. This will "destroy" the Url change you just made. To solve these problems:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.