-->

Tuesday, September 1, 2015

Show Confirmation Message in ASP.NET C#

Show Confirmation Message in ASP.NET C#

Introduction

In this article i will show you how to popup confirmation dialog box using ASP.NET C#. Also you can say example of Confirmation dialog box in asp.net. This thing is possible by two ways first one, you can use AJAX ConfirmationExtender and second one is JavaScript.

You can check this video to do this things by two ways



I-Method (AJAX)


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default9.aspx.cs" Inherits="Default9" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
   
        <br />
   
        <asp:Button ID="Button1" runat="server" Text="Delete Record" />
   
        <cc1:ConfirmButtonExtender ID="Button1_ConfirmButtonExtender" runat="server" BehaviorID="Button1_ConfirmButtonExtender" ConfirmText="Are you sure you want to delete it" TargetControlID="Button1" />
   
    </div>
    </form>
</body>
</html>

II- Method


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default9.aspx.cs" Inherits="Default9" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script>
        function validate() {
            confirm("Are you sure");
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
     
        <br />
   
        <asp:Button ID="Button1" runat="server" Text="Delete Record" OnClientClick="validate();" />
   
    </div>
    </form>
</body>
</html>

In the first method we used ConfirmButtonExtender of AJAX control toolkit. In the second method we used java script

Read other related articles

Also read other articles

© Copyright 2013 Computer Programming | All Right Reserved