如何给出提示信息&之后将页面重定向到asp.net中的另一个按钮点击事件

how to give prompt message & after that redirecting page to another in button click event in asp.net

本文关键字:net asp 另一个 事件 按钮 重定向 提示信息 amp 之后      更新时间:2023-09-26

嗨我有一个提交按钮来提交页面。当我点击提交按钮时,它应该会给出提示信息,比如"你真的确定要提交那个页面吗",如果是的话,它应该重定向到另一个页面。我使用的代码如下:

RegisterStartupScript("myAlert", "<script>alert('Are you sure about to submit the test?')</script>");
Response.Redirect("Result.aspx");

但它直接重定向页面,而不向用户提示消息。怎么可能?Asp.net c#

您可以这样做。。

<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="javascript:return 
confirm('Are you sure about to submit the test?');" OnClick="Button1_Click" />

然后在代码后面。。。

protected void Button1_Click(object sender, EventArgs e)
{
    Response.Redirect("Result.aspx");
}

Ajax Control Toolkit中有一个modalpopup,也许对您有用?

样品:http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/ModalPopup/ModalPopup.aspx

不记得确切的语法,但您需要捕获单击的值,在此基础上,您可以返回true或false。True将提交页面