简体   繁体   English

在asp.net中单击按钮重定向到下一页之前,如何应用javascript警报

[英]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". 我有一个登录页面,该页面重定向到管理主页,即“ frmAdminHomePage.aspx”。 This page is linked with masterpage "Admin.master". 该页面与母版页“ Admin.master”链接。 This both files are in same folder called "Admin". 这两个文件位于名为“ Admin”的同一文件夹中。 My question when i click button the following code does show error . 我的问题是,当我单击按钮时,以下代码确实显示错误。 The resource cannot be found. 无法找到该资源。 , Requested URL: /Visitors/Admin/frmAdminHome.aspx ,要求的网址:/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 ,要求的网址:/Visitors/Admin/frmAdminHome.aspx

Try window.location ='../Admin/frmAdminHome.aspx' or window.location ='./Admin/frmAdminHome.aspx' . 尝试window.location ='../Admin/frmAdminHome.aspx'window.location ='./Admin/frmAdminHome.aspx' I assume the actual link for your Admin area is not under current path. 我认为您的“管理”区域的实际链接不在当前路径下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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