How to use JavaScript Confirm() box in ASP.Net

In this asp.net article i will explain how to use javascript confirm box in asp.net.

Confirmation javascript used to confirm an important actions that are taking place on a website. For example, they may be used to confirm an order submission or logout from the website, change the login password we confirm that action before they done..

JavaScript confirm box pops up, the user will have two option  OK or Cancel.

Here we will learn with an ASP.Net Example.

Write javascript confirm() box code in <head> tags like below :

<head runat=”server”>
<script type=”text/javascript” language=”javascript”>
function mm()
{
var my = confirm(“Do you want to Exit?”);
if( my == true )
{
alert(“Ok, Thank you Bye Bye.”);
return true;
}
else
{
alert(“Welcome back to system.”);
return false;
}
}
</script>
</head>

First Design asp.net web form for learn javascript confirm() box.

JavaScript confirm box in asp.net

JavaScript confirm box in asp.net

Here is the asp.net Button control code :

<asp:Button ID=”Button4″ runat=”server” Font-Bold=”True”
Text=”Confirm Box()” onclientclick=”mm()” Height=”35px” />

Here we use onclientclick property of button control for call javascript function.

JavaScript confirm box in asp.net

JavaScript confirm box in asp.net

 

Wen you click OK button on confirm box, Messagebox shows the “OK, Thank you Bye Bye”.

JavaScript confirm box in asp.net

JavaScript confirm box in asp.net

Wen you click Cancel button on confirm box, Messagebox shows the “Welcome back to System”.

JavaScript confirm box in asp.net

JavaScript confirm box in asp.net

I hope this asp.net example of confirm box will help you……

Leave a Reply

Your email address will not be published. Required fields are marked *

3 + 9 =


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">