简体   繁体   中英

How to apply javascript alert before redirecting to next page on button click in asp.net

I have a login page which redirects to admin home page ie "frmAdminHomePage.aspx". This page is linked with masterpage "Admin.master". This both files are in same folder called "Admin". My question when i click button the following code does show error . The resource cannot be found. , Requested URL: /Visitors/Admin/frmAdminHome.aspx

Code is as follow

 protected void btnLogin_Click(object sender, EventArgs e)
    {
ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Alert worked succesfully');window.location ='~/Admin/frmAdminHome.aspx';", true);
}

Error as it gives in browser. The resource cannot be found. , Requested URL: /Visitors/Admin/frmAdminHome.aspx

Try window.location ='../Admin/frmAdminHome.aspx' or window.location ='./Admin/frmAdminHome.aspx' . I assume the actual link for your Admin area is not under current path.

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