AJAX Control Toolkit Tutorial——ConfirmButton(确定按钮)

本文详细介绍了ASP.NET AJAX控件库中的ConfirmButtonExtender控件,包括其主要属性如TargetControlID、ConfirmText等,并说明如何使用ModalPopup控件来替代默认的确认对话框。

  

TargetControlID - The ID of the Button Control to extend.(要进行扩展的按钮控件)

ConfirmText - The confirmation text to display.HTML entities can be used,such as 
for a newline character.(要显示的确认文本,可以是HTML实体,如一个换行符)

OnClientCancel - The Client script to execute when the Cancel button is clicked in the confirm dialog box.(当单击确认对话框“取消”按钮时所执行的客户端脚本)

ConfirmOnFormSubmit - true if the confirm dialog box should not be displayed until just before the form is submitted.This is useful if the page contains ASP.NET validator controls and the confirm dialog box should be displayed only after all validation checks pass.false(default).(当值设置为true时,确认对话框只有在表单提交时才显示,这在页面包含ASP.NET验证控件(也就是确认对话框只有在所有验证控件都通过时才显示)是很有用的。)

DisplayModalPopID - Speicifies the ID of a ModalPopup control to use to display the confirm dialog box.instead of the default window.confirm window. When you use the DisplayModalPopupID property, the following conditions must be met:

a.The ModalPopup control must be configured with the same TargetControlID value as the ConfirmButton extender. (It will work properly if the ConfirmButton extender is disabled.)

b.The ModalPopup control must specify the OkControlID or the CancelControlID properties in order to identify the buttons that correspond to the the OK and Cancel buttons in the confirm dialog box.

c.The ModalPopup must not specify a OnOkScript or OnCancelScript property.

(这个属性(低版本中没有)比较麻烦哦,不过如果你想追求更好的表现效果的话,可以与ModalPopup组合使用,当使用该属性的时候也就代替了默认的JavaScript window.confirm 窗口,而且你必须作如下设置:

a.ModalPopup控件的TargetControlID必须和ConfirmButton控件的一致; 
b.ModalPopup控件中必须设置有效的OkControlID和CancelControlID以和确认对话框的“确认”、“取消”按钮相一致;

c.必须设置对应的OnOkScript和OnCancelScript处理脚本。)

参看ModalPopup

 <Demo>

1 <asp:ScriptManager ID="ScriptManager1" runat="server" />
2 <div>
3 <br />
4 <asp:Label ID="Label1" runat="server" Width="273px"></asp:Label><br />
5 <br />
6 <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" Width="175px" />
7 <ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" TargetControlID="Button1"
8 ConfirmText="Are you sure you want to submit ?">
9 </ajaxToolkit:ConfirmButtonExtender>

 protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text
= "Text from the serverside.";
}

转载于:https://www.cnblogs.com/January/archive/2011/08/05/2128371.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值