ConfirmButton控件,該控件用來對某個按鈕進行確認。
下面的示例顯示了當單擊按鈕後會關聯確認按鈕,如果單擊確定,會對先前單擊的按鈕進行處理。
實例代碼如下:
頁面部分:
<%...@ Page Language="C#" AutoEventWireup="true" CodeFile="ConfirmButtonDemo.ASPx.cs"
Inherits="ConfirmButtonDemo" %>
<%...@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="ASP" %>
<%...@ Register Assembly="AjaxControlToolkit" Namespace="AJaxControlToolkit" TagPrefix="cc1" %>
<!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">
<div>
<ASP:ScriptManager ID="ScriptManager1" runat="server">
</ASP:ScriptManager>
<ASP:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<p>
<ASP:LinkButton ID="LinkButton" runat="server" OnClick="Button_Click">Click Me
</ASP:LinkButton>
<cc1:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server"
TargetControlID="LinkButton" ConfirmText="確定點擊這個 LinkButton?" />
<br />
<br />
<ASP:Button ID="Button" runat="server" Text="Click Me" OnClick="Button_Click" /><br />
<cc1:ConfirmButtonExtender ID="ConfirmButtonExtender2" runat="server"
TargetControlID="Button" ConfirmText="確定點擊這個 Button?" />
<br />
</p>
<asp:Label ID="Label1" runat="server"></ASP:Label>
</ContentTemplate>
</ASP:UpdatePanel>
</div>
</form>
</body>
</Html>
代碼部分:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class ConfirmButtonDemo : System.Web.UI.Page
..{
protected void Page_Load(object sender, EventArgs e)
...{
}
protected void Button_Click(object sender, EventArgs e)
...{
Label1.Text = "你點擊了 " + ((Control)sender).ID + "