简体   繁体   中英

how to open a different page when cancel button is clicked in the Confirm dialog?

I just need to add an else condition in the following confirm function. So that if cancel is clicked on the box another page opens up.

ScriptManager.RegisterClientScriptBlock(
    Me,
    GetType(Page),
    "confirm ",
    "{ confirm('Hello World'); window.location = 'page.aspx'  }",
    True
);

Any help in this regard would be great.

Try

ScriptManager.RegisterClientScriptBlock(
    Me,
    GetType(Page),
    "confirm ",
    "{ if(confirm('Hello World')===false) { window.location = 'page.aspx' } }",
    True
);

have you tried this?

ScriptManager.RegisterClientScriptBlock(
    Me,
    GetType(Page),
    "confirm ",
    "{
      var r = confirm('Hello World'); 
      if (r == true)
         window.location = 'page.aspx';
      else
         windo.location = THE_OTHER_PAGE;
     }",
    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