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 c#
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 c#
Share Improve this question edited Jul 6, 2011 at 18:26 Muhammad Akhtar 52.2k37 gold badges139 silver badges191 bronze badges asked Apr 21, 2011 at 4:44 user707294user707294 3111 gold badge7 silver badges21 bronze badges 1- Give the message in the clientclick of button. – Mahesh KP Commented Apr 21, 2011 at 4:50
3 Answers
Reset to default 5you 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/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