Posted by : Anwar Hossain
Category : How to use ajax toolkit in C#

How to use Ajax ConfirmButtonExtender in using c#

Dear viewers I will show how to use ASP.Net AJAX Control Toolkit ConfirmButtonExtender at the time of gridview row data deleting . In this case I have used virtual data to show this operation but real time data will be deleted from database.I have also used Link button instead of asp asp:CommandField .At first drag ConfirmButtonExtender on the page and assign the link button to ConfirmButtonExtender using it’s TargetControlID Properties and write warning value it’s ConfirmText properties .

Use ajax ConfirmButtonExtender in ASP.NET C#


<%@ RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="asp"%>

 <html xmlns="">
<head runat="server">
  <title>Delete Confirmation</title>
  <form id="form1" runat="server">
  <asp:GridView ID="Studentlist" CssClass="Grid" runat="server" OnRowDeleting="OnRowDeleting"
  AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None">
  <AlternatingRowStyle BackColor="White" />
  <asp:BoundField DataField="StudentName" HeaderText="StudentName" />
  <asp:BoundField DataField="Address" HeaderText="Address" />
  <asp:BoundField DataField="Phone" HeaderText="Phone" />
  <asp:BoundField DataField="JoingDate" HeaderText="JoingDate" />
  <asp:LinkButton ID="lnkDelete" runat="server" CommandName="Delete">Delete</asp:LinkButton>
  <asp:ConfirmButtonExtender ID="DeleteConfirmation" runat="server" ConfirmText="Are you sure to delete this Data ...?"
  Enabled="True" TargetControlID="lnkDelete">
  <EditRowStyle BackColor="#2461BF" />
  <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
  <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
  <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
  <RowStyle BackColor="#EFF3FB" />
  <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
  <SortedAscendingCellStyle BackColor="#F5F7FB" />
  <SortedAscendingHeaderStyle BackColor="#6D95E1" />
  <SortedDescendingCellStyle BackColor="#E9EBEF" />
  <SortedDescendingHeaderStyle BackColor="#4870BE" />
  <asp:ScriptManager ID="ScriptManager1" runat="server">


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


protected void Page_Load(object sender, EventArgs e)
  if (!IsPostBack)
  if (!Page.IsPostBack)
  ViewState["StudentList"] = GetStudentList();
  protected void BindGrid()
  Studentlist.DataSource = ViewState["StudentList"];
  static DataTable GetStudentList()
  //I  Have Created Virtual table
  DataTable table = new DataTable();
  table.Columns.Add("StudentName", typeof(string));
  table.Columns.Add("Address", typeof(string));
  table.Columns.Add("Phone", typeof(string));
  table.Columns.Add("JoingDate", typeof(DateTime));
  // Now have created some row to fill the the datatable
  table.Rows.Add( "Samim", "Dhaka","01856587548", "11/5/2007");
  table.Rows.Add("Ahsan", "Chittagong", "01856587548","12/ 5/2007");
  table.Rows.Add("Nirub", "Sylhet", "01856587544", "11/10/ 2007");
  table.Rows.Add("Zaman", "Rajsahi", "01856587578", "11 /15/ 2007");
  table.Rows.Add("Habib", "Barisal", "01856587548", "11 /5 / 2010");
  table.Rows.Add("Roman", "Chandpur", "01856587548", "11 /5 / 2010");
  table.Rows.Add("Iqbal Hossain", "Noakhali", "01856587548", "11 /5 / 2010");
  return table;
  protected void OnRowDeleting(object sender, GridViewDeleteEventArgs e)
  int index = Convert.ToInt32(e.RowIndex);
  DataTable dt = ViewState["StudentList"] as DataTable;
  ViewState["dt"] = dt;

Out Put




Realted Article Headline

How to use TextBoxWatermarkExtender in using c#
How to use Ajax AutoCompleteExtender control in using c#
How to use Ajax Collapsible panel control in c#
How to use ASP.Net AJAX Control Toolkit ModalPopupExtender Control in c#
how to add an Ajax Control Toolkit Accordion to a page
How to use html editor Ajax control toolkit example in c#
How to use Ajax ConfirmButtonExtender in using c#
how to use ajax calendar extender in asp net c#
How to use ajax toolkit FilteredTextBox Control in c#

Article Category

How to create control dynamically
Learn HTML for beginner
DataList example in C Sharp
Mail sending in c#
State Management in ASP C #
Basic sql tutorial for Beginner
DataTable example in ASP.Net C#
How to use LINQ in ASP.NET C# c # basic tutorial
How to use ajax toolkit in C#
How to use different types of validation control using c#
How to use grid view in c#
Protected by Copyscape Online Plagiarism Detection