July 17, 2012

ConfirmButtonExtender Control from AJAX Control Tool kit

To know how to use Controls from AJAX Control Toolkit follow this post
http://www.dotnetissues.com/2012/07/alwaysvisiblecontrolextender-from.html

When there is some critical Operation on a button click its a good idea to prompt  'Are you sure' message to the user and this can be easily accomplished by ConfirmButtonExtender  control from AJAXControlToolkit

Set the TargetControlId and ConfirmText Property of the ConfirmButtonExtender
As per below code sample



ConfirmButtonExtender.aspx


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


<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>


<!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></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:scriptmanager ID="Scriptmanager1" runat="server" ></asp:scriptmanager>
    <asp:ConfirmButtonExtender ID="ConfirmButtonExtender1" ConfirmText="Are you sure want to delete this" TargetControlID="btnDelete" runat="server"></asp:ConfirmButtonExtender>
    <asp:Button ID="btnDelete" runat ="server" Text ="DELETE"    />
    <div>
    
    </div>
    </form>
</body>
</html>

when you click on the delete button below prompt will come.



No comments:

Post a Comment