简体   繁体   中英

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#

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?

Sample : 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 will submit the page

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