In this article I will explain a simple tutorial with an example, how to implement ASP.Net AJAX ConfirmButtonExtender control of the ASP.Net Ajax Control Toolkit Library using C# and VB.Net.
The ASP.Net AJAX ConfirmButtonExtender control is used to attach JavaScript Confirmation Box to the ASP.Net Button, LinkButton and ImageButton controls without writing any JavaScript code.
Using the ASP.Net Ajax Control ToolKit ConfirmButtonExtender Control
1. Register the AJAX Control Toolkit Library after adding reference to your project.
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
2. Drag an ASP.Net AJAX ToolkitScriptManager on the page.
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
3. Then you need to add the ASP.Net AJAX ConfirmButtonExtender control next to the Button control which you want to display the JavaScript Confirmation Box.
There are two important properties:
1. TargetControlID – ID of the Button to which the ASP.Net AJAX ConfirmButtonExtender control is associated.
2. ConfirmText – The text to be displayed on the JavaScript Confirmation Box.
There is one Client Side event:
1. OnClientCancel – This event if set will call the specified JavaScript function when the Cancel button is clicked in the JavaScript Confirmation Box.
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
<table border="0" cellpadding="0" cellspacing="2">
            <asp:TextBox ID="txtName" runat="server" />
            <asp:Button ID = "btnSubmit" Text="Submit" runat="server" OnClick = "Submit" />
            <asp:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" ConfirmText = "Do you want to Submit?" TargetControlID = "btnSubmit" OnClientCancel = "OnClientCancel">
<script type="text/javascript">
    function OnClientCancel() {
        alert("You clicked Cancel!");
Server Side Click event handler of the Button
When the OK Button of the JavaScript Confirmation Box displayed using the ASP.Net AJAX ConfirmButtonExtender control is clicked, then the following event handler is executed which simply displays a JavaScript Alert Message Box indicating that the OK Button was clicked.
protected void Submit(object sender, EventArgs e)
    ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('You clicked OK!');", true);
Ajax Control ToolKit ConfirmButtonExtender Tutorial with example in ASP.Net