Skip to main content

CONFIRMATION BOX WITH YES NO BUTTONS USING AJAX MODAL POPUP EXTENDER IN ASP.NET

Here  I am explained with an example , how to built a confirmation box (confirm box) with Yes , No Buttons or Options using AJAX Control Toolkit ModalPopupExtender control Modal Popup in ASP.Net
In this article, I will explain how to use ASP.Net AJAX Control Toolkit ConfirmButtonExtender with ModalPopupExtender Modal Popup in order to style the ConfirmButtonExtender dialog and also to make it look same in all browsers.
 
By default the Confirmation Box displayed in Internet Explorer as follows
ASP.Net AJAX ConfirmButtonExtender with ModalPopupExtender Example

In the following example I will make use of a dummy Button with Confirmation Box using ConfirmButtonExtender with ModalPopupExtender Modal Popup.
HTML Markup
First we need to register the AJAX Control Toolkit on the page
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
Below is an ASP.Net Button with associated ConfirmButtonExtender and ModalPopupExtender for displaying the confirmation box.
  <asp:Button runat="server" Width="130px" Text="Book Room" ID="btnSubmit" OnClick="btnSubmit_Click"
                                            ToolTip="Click To Book Rooms" />
 <ajaxToolkit:ConfirmButtonExtender ID="cbe" runat="server" DisplayModalPopupID="mpe"
            TargetControlID="btnSubmit" ConfirmText="Are you sure you want to Book Room Now?" />
                    <ajaxToolkit:ModalPopupExtender ID="mpe" runat="server" PopupControlID="pnlPopup"
                                TargetControlID="btnSubmit" OkControlID="btnYes" CancelControlID="btnNo" BackgroundCssClass="modalBackground">
                                        </ajaxToolkit:ModalPopupExtender>
           <asp:Panel ID="pnlPopup" runat="server" CssClass="modalPopupConfirm" Style="display: none">
                                            <div class="header">
                                                Confirmation Details
                                            </div>
                                            <div class="body">
                                         <span class="ui-icon ui-icon-alert" style="margin: 8px 8px 0px 10px; float: left;">
                                                </span>Are you sure you want to Book Room(s) now ?
                                            </div>
                                            <div class="footer" align="right">
                                                <asp:Button ID="btnYes" runat="server" Text="Yes" />
                                                <asp:Button ID="btnNo" runat="server" Text="No" />
                                            </div>
                                        </asp:Panel> 
In order to associate a ConfirmButtonExtender with ModalPopupExtender we need to set the following properties
1. TargetControlID – The TargetControlID of both the ConfirmButtonExtender with ModalPopupExtender must be equal.
2. DisplayModalPopupID – The DisplayModalPopupID property of the ConfirmButtonExtender must be set with the ID ModalPopupExtender Modal Popup that we need to display as Confirmation Box.
3. OkControlID and CancelControlID – Since we want the ModalPopupExtender Modal Popup to work as Confirmation Box, it is necessary that we have two buttons one for OK and one for Cancel.
The above three points are necessary so that when the Target Control of the ConfirmButtonExtender is triggered the ModalPopupExtender Modal Popup is displayed.
For more details on using the ASP.Net AJAX ModalPopupExtender please refer article Building Modal Popup using ASP.Net AJAX ModalPopupExtender Control
 
 Model PopUp Style :
<style type="text/css">
        .modalPopupConfirm
        {
            background-color: #FFFFFF;
            width: 300px;
            border: 3px solid #0DA9D0;
        }
        .modalPopupConfirm .header
        {
            background-color: #2FBDF1;
            height: 30px;
            color: White;
            line-height: 30px;
            text-align: center;
            font-weight: bold;
            width: 300px;
        }
        .modalPopupConfirm .body
        {
            min-height: 50px;
            line-height: 30px;
            font-weight: bold;
        }
        .modalPopupConfirm .footer
        {
            padding: 3px;
        }
        .modalPopupConfirm .yes, .modalPopup .no
        {
            height: 23px;
            color: White;
            line-height: 23px;
            text-align: center;
            font-weight: bold;
            cursor: pointer;
        }
        .modalPopupConfirm .yes
        {
            background-color: #2FBDF1;
            border: 1px solid #0DA9D0;
        }
        .modalPopupConfirm .no
        {
            background-color: #9F9F9F;
            border: 1px solid #5C5C5C;
        }
    </style>
Out Put :
I hope this will be helpful for you. I would like to have any feedback from you.  Your valuable feedback, question, or comments about this article are always welcome.


Comments

Popular posts from this blog

ASP.NET e-Commerce website GridView with Product Listing

Introduction : E-Commerce web applications are everywhere these days, and many share a common set of functionality. In this article, I will show how to use the GridView and ListView controls to build a powerful product page with many of the features found on today's e-commerce sites. We'll build a bicycle store product grid using some free clip art bicycle images. The example files are user controls which can be easily added to a page. We're only using three images here to keep the size of the sample application small. In previously I was explained about  Sending Email from Asp.net With Dynamic Content  ,  How To Export gridview data to Excel/PDF , CSV Formates in asp.net C#  , How to print Specific Area in asp.net web page How To- Search records or data in gridview using jQuery  . A shopping cart application would require to display the products in a multi column grid, rather than a straight down list or a table. The each item in a product grid would have

How to hide url parameters in asp.net

There are different ways to Hide the URL in asp.net , you can choose any one from bellow options . Previously I was Explained about the  Difference between Convert.tostring and .tostring() method Example  ,   Reasons to use Twitter Bootstrap , How to Register AJAX toolkit in web.config file in asp.net a) Using Post Method b) Using Of Session . c) URL Encoding & decoding process . d) Using Server.Transfer() instead of Response.Redirect() method (1)Use a form and POST the information. This might require additional code in source pages, but should not require logic changes in the target pages (merely change Request.QueryString to Request.Form). While POST is not impossible to muck with, it's certainly less appealing than playing with QueryString parameters. (2)Use session variables to carry information from page to page. This is likely a more substantial effort compared to (1), because you will need to take session variable checking into account (e.g. the

Nested GridView in ASP.NET Using c# with show/hide

In This example shows how to create Nested GridView In Asp.Net Using C# And VB.NET With Expand Collapse Functionality. Previous post I was Explained about the   ASP.NET e-Commerce website GridView with Product Listing  ,  How To Export gridview data to Excel/PDF , CSV Formates in asp.net C# , Sending Email from Asp.net With Dynamic Content  ,  SQL Server- Case Sensitive Search in SQL Server I have used JavaScript to Create Expandable Collapsible Effect by displaying Plus Minus image buttons. Customers and Orders Table of Northwind Database are used to populate nested GridViews. Drag and place SqlDataSource from toolbox on aspx page and configure and choose it as datasource from smart tags Go to HTML source of page and add 2 TemplateField in <Columns>, one as first column and one as last column of gridview. Place another grid in last templateField column. Markup of page after adding both templatefields will like as shown below. HTML SOURCE < a