简体   繁体   中英

Best way to get a label to change text/ redirect page after delay

I'm trying to implement in asp.net (c#) the following flow:

  1. User clicks on a button
  2. A text label presented
  3. Waiting for 3 seconds
  4. Reloading the page

I have been trying a few things in c# but i'm starting to think it's easier implement this in javascript

Any help/suggestions would be greatly appreciated.

try like this

 <script type="text/javascript"> function callthis() { setTimeout('window.location = "home.aspx"', 3000); } </script> 

call this from server side on button click

If you Used Update Panels Then You can Use:

ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "callthis();", true);

Other Wise You can Use

ClientScript.RegisterStartupScript
        (GetType(),Guid.NewGuid().ToString(), "callthis();",true);

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM