connectseekers.com

Wednesday, 17 June 2015

Confirmation Message With Yes, No Button In Asp.Net Using ConfirmButtonExtender and ModalPopupExtender

6/17/2015 - By Pranav Singh 0

This article will show you how you can display confirmation message with yes, no button in asp.net using Ajax Control Toolkit, confirmbuttonextender and modalpopupextender. In this I have user C# to display the message after user click on Yes.


So here is article here is the code.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm5.aspx.cs" Inherits="WebApplication2.WebForm5" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Confirmation Message With Yes, No Button In Asp.Net Using ConfirmButtonExtender and ModalPopupExtender</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <cc1:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" TargetControlID="Button1"
            ConfirmText="Are you sure you want to submit data?" DisplayModalPopupID="ModalPopupExtender1">
        </cc1:ConfirmButtonExtender>
        <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="Button1"
            PopupControlID="divMessage" CancelControlID="btnNo">
        </cc1:ModalPopupExtender>
    </div>
    <div id="divMessage" runat="server" style="border: 1px solid black;">
        <table style="width: 300px; height: 100px; background-color: White; border: 1 solid black;
            border: 1; border-collapse: collapse">
            <tr>
                <th style="background-color: Gray; color: White; height: 30px;">
                    Confirm Message
                </th>
            </tr>
            <tr>
                <td>
                    Are you sure do you want to submit form?
                </td>
            </tr>
            <tr>
                <td align="center">
                    <asp:Button ID="btnYes" runat="server" Text="Yes" OnClick="btnYes_Click" />&nbsp;&nbsp;
                    <asp:Button ID="btnNo" runat="server" Text="No" />
                </td>
            </tr>
        </table>
    </div>
    <asp:Button ID="Button1" runat="server" Text="Show Confirmation Message" /><br />
    Current Date Time :
    <asp:Label ID="lblMessage" runat="server" Style="color: #FF0000" Text=""></asp:Label>
    </form>
</body>
</html>

Now on yes button click add the below code to display the message.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication2
{
    public partial class WebForm5 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnYes_Click(object sender, EventArgs e)
        {
            lblMessage.Text = DateTime.Now.ToString();
        }
    }
}

In above code as user click on yes above click event will get called and display on the label control. Now we have done run the application to check the output.

DOWNLOAD

About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com
Email Id : contact@aspdotnet-pools.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Top jQuery Plugins

Global Classified : Connectseekers.com
© 2014
back to top