ConfirmButton控件,该控件用来对某个按钮进行确认。
下面的示例显示了当单击按钮后会关联确认按钮,如果单击确定,会对先前单击的按钮进行处理。
实例代码如下:
页面部分:
代码部分:
下面的示例显示了当单击按钮后会关联确认按钮,如果单击确定,会对先前单击的按钮进行处理。
实例代码如下:
页面部分:
<%
@PageLanguage
=
"
C#
"
AutoEventWireup
=
"
true
"
CodeFile
=
"
ConfirmButtonDemo.aspx.cs
"
Inherits = " ConfirmButtonDemo " %>
<% @RegisterAssembly = " System.Web.Extensions,Version=1.0.61025.0,Culture=neutral,
PublicKeyToken=31bf3856ad364e35 "
Namespace = " System.Web.UI " TagPrefix = " asp " %>
<% @RegisterAssembly = " AjaxControlToolkit " Namespace = " AjaxControlToolkit " TagPrefix = " cc1 " %>
<! DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//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" > ClickMe
</ asp:LinkButton >
< cc1:ConfirmButtonExtender ID ="ConfirmButtonExtender1" runat ="server"
TargetControlID ="LinkButton" ConfirmText ="确定点击这个LinkButton?" />
< br />
< br />
< asp:Button ID ="Button" runat ="server" Text ="ClickMe" 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 >
Inherits = " ConfirmButtonDemo " %>
<% @RegisterAssembly = " System.Web.Extensions,Version=1.0.61025.0,Culture=neutral,
PublicKeyToken=31bf3856ad364e35 "
Namespace = " System.Web.UI " TagPrefix = " asp " %>
<% @RegisterAssembly = " AjaxControlToolkit " Namespace = " AjaxControlToolkit " TagPrefix = " cc1 " %>
<! DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//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" > ClickMe
</ asp:LinkButton >
< cc1:ConfirmButtonExtender ID ="ConfirmButtonExtender1" runat ="server"
TargetControlID ="LinkButton" ConfirmText ="确定点击这个LinkButton?" />
< br />
< br />
< asp:Button ID ="Button" runat ="server" Text ="ClickMe" 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,EventArgse)
{
}
protected void Button_Click( object sender,EventArgse)
{
Label1.Text = " 你点击了 " + ((Control)sender).ID + " 时间: " + DateTime.Now.ToLongTimeString() + " . " ;
}
}
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,EventArgse)
{
}
protected void Button_Click( object sender,EventArgse)
{
Label1.Text = " 你点击了 " + ((Control)sender).ID + " 时间: " + DateTime.Now.ToLongTimeString() + " . " ;
}
}