Wednesday 22 May 2013

Yes/No Message Box ASP.NET

Yes/No Message Box ASP.NET 

You might have got into this situation of displaying a message box to confirm the occurrence of  an event similar to the Yes/No message box in Windows Forms. To achieve the same functionality in that too dynamically you need few JavaScript codes and  you would be able to achieve the same easily..

Design Part:

<html xmlns="" >
<head runat="server">
    <title>Confirm Yes No Demo</title>
        <script type="text/javascript" language="javascript">
        function ConfirmYesNo()
          if (confirm("Are you sure?")==true)
            return true;
            document.getElementById('Label1').innerHTML = '';
            alert("You have Cancelled the Operation.");
            return false;
    <form id="form1" runat="server">
    <asp:Button ID="Button1" runat="server" Text="Click Me" onclick="Button1_Click" OnClientClick="return ConfirmYesNo();" />
    <br />
    <br />
        <asp:Label ID="Label1" runat="server"></asp:Label>


    protected void Button1_Click(object sender, EventArgs e)
        Label1.Text = "";
        Label1.Text = "Welcome to";



Thank You for Your Comments. We will get back to you soon.

back to top