简体   繁体   English

如何给出提示信息,以及在重定向页面到asp.net中的另一个按钮单击事件之后

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

Hi I have one submit button to submit the page. 嗨,我有一个提交按钮来提交页面。 When i click on submit button then it should give prompt message like "are you sure to submit that page really" if yes then it should redirect the another page. 当我单击“提交”按钮时,它应该给出提示消息,例如“您确定要提交该页面吗?”,如果是,则它应该重定向另一个页面。 I used code as follows: 我使用如下代码:

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

But its directly redirecting the page without promting to user with message. 但是它直接重定向页面,而不会向用户提示消息。 How its possible? 怎么可能? Asp.net c# ASP.NET C#

you can do like.. 你可以做..

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

and then in code behind... 然后在后面的代码中...

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

There's a modalpopup in Ajax Control Toolkit, maybe that would work for you? Ajax Control Toolkit中有一个modalpopup,也许对您有用?

Sample : http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/ModalPopup/ModalPopup.aspx 范例: http//www.asp.net/ajax/ajaxcontroltoolkit/Samples/ModalPopup/ModalPopup.aspx

Dont remember the exact syntax but you need to capture the clicked value and based on that you can do either a return true or a return false. 不记得确切的语法,但是您需要捕获单击的值,并根据此值可以返回true或false。 True will submit the page True将提交页面

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

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