最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - how to give prompt message & after that redirecting page to another in button click event in asp.net - Stack Overfl

programmeradmin1浏览0评论

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
Add a ment  | 

3 Answers 3

Reset to default 5

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/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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论