.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> ASP.NET >> Post New Resource Bookmark and Share   

 Subscribe to Articles

How to show Alert and Confirmation Message box in ASP.NET?

Posted By:Syed Shakeer Hussain       Posted Date: September 01, 2009    Points: 10    Category: ASP.NET    URL: http://www.dotnetspark.com  
 

In this Article Biggeners can learn how to disaply a Message Box in Asp.net using JavaScritp.

1)Alert Message Box:-This type of Message Box is used to give Alert Information to the User.Thsi can be done by using 'alert' method.Use the Alert mehtod in tags by using a function with method name.Call this function On 'Clientclick event in Button as follows in Below code.

eg:alert("write Message here")

Image of Alert Message Box

<head runat="server">

<title>Untitled Pagetitle>

<script type="text/Javascript" language ="javascript" >

function alert_meth()

{

alert("Client Side MessageBox");

}

script>

head>

<body>

<form id="form1" runat="server">

<div>

<asp:Button ID="Button1" runat="server" Style="z-index: 100; left: 64px; position: absolute;

top: 88px" Text="Alert" OnClientClick ="alert_meth()" Font-Bold="True" ForeColor="Red" Width="72px"/>

2)Confirm Message Box:-This type of Message Box is used to give warning to the user.Suppsoe user going to delete records at that time this type of message box is used to give confirmation about the action takes place or not by showing two Buttons as "YES'" and "NO".If the User click on 'YES' Button it returns Boolean 'True'  and for 'NO' button it returns Boolean 'False'.

Image of Confirm Message Box

<head runat="server">

<title>Untitled Pagetitle>

<script type="text/Javascript" language ="javascript" >

function confirm_meth()

{

if( confirm("Do you want to continue!Click 'YES'")==true)

{

document.writeln ("You had clic on 'YES' Button");

}

else

{

document.writeln ("You had clic on 'NO' Button");

}

}

script>

head>

<body>

<form id="form1" runat="server">

<div>

<asp:Button ID="btnconfirm" runat="server" Font-Bold="True" ForeColor="Red" Style="z-index: 101;

left: 272px; position: absolute; top: 208px" Text="Confrimation MsgBox" OnClientClick =" return confirm_meth()" Width="160px" />

 

Thanks for Reading my Article!

Syed Shakeer Hussain


 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend