Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Confirmation message box in webapplication

Tags:

c#

asp.net

Am using the below message box in asp.net web application. Now i want to convert this message box as a confirmation message box and do something when it is true else means reject the application.

   ScriptManager.RegisterStartupScript(this, this.GetType(), "temp", "<script language='javascript'>alert('Are you sure, you want to apply?');</script>", false);
like image 947
Milton Fernando Avatar asked Oct 19 '25 16:10

Milton Fernando


2 Answers

I think you are going about this the wrong way. You should display this confirmation before posting back, and then only post back if they choose to "Apply".

Using ASP.NET web controls, the Button control has an OnClientClick property which can be used to call javascript prior to Http POST:

You could do something like this:

<asp:button id="btn"
            runat="server"
            Text="Apply"
            OnClientClick="return confirm('Are you sure you wish to apply?');"
            OnClick="btn_Click" />
like image 65
Curtis Avatar answered Oct 22 '25 06:10

Curtis


register script bellow instead of alert

<script type="text/javascript">
var r=confirm("Are you sure you are sure?")
if (r==true)
{
  //You pressed OK!
}
else
{
  //You pressed Cancel!
}
</script>
like image 33
Arsen Mkrtchyan Avatar answered Oct 22 '25 05:10

Arsen Mkrtchyan