AJAX Tookits -- ConfirmButton

在AJAX Toolkits中有个ConfirmButton的扩展控件,该控件只能应用与Button类型的控件,例如Button和LinkButton。

当你点击按键之后,系统会弹出一个确认框。基本属性如下:

  • TargetControlID - Button或Link的控件编号.
  • ConfirmText - 弹出对话框上显示的信息
  • OnClientCancel - 点击取消按键后所调用的程序,该程序写在前台.
  • ConfirmOnFormSubmit - True if the confirm dialog should wait until just before the form submits to display. This is useful when ASP.NET validators are in use and the confirm should be shown only after all validators pass.
  • DisplayModalPopupID - 弹出确认框的样式。如果显示了该信息就需要人工创建一个ModalPopupExtender控件,自定义相关信息,例如 :
    <asp:Button ID="Button" runat="server" Text="Click Me" OnClick="Button_Click" /><br />
    <ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender2" runat="server" TargetControlID="Button"
                        OnClientCancel="cancelClick" DisplayModalPopupID="ModalPopupExtender1" />
                    <br />
    <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="Button"
                        PopupControlID="PNL" OkControlID="ButtonOk"
                        CancelControlID="ButtonCancel"      BackgroundCssClass="modalBackground" />
    <asp:Panel ID="PNL" runat="server" Style="display: none; width: 200px; background-color: White;
                        border-width: 2px; border-color: Black; border-style: solid; padding: 20px;">
                        Are you sure you want to click the Button?
                        <br />
                        <br />
                        <div style="text-align: right;">
                            <asp:Button ID="ButtonOk" runat="server" Text="OK" />
                            <asp:Button ID="ButtonCancel" runat="server" Text="Cancel" />
                        </div>
     </asp:Panel>

代码示例:

 

<script type="text/javascript" language="javascript">
        function confirmCancel()
        {
            var label = document.getElementById('ctl00_ContentPlaceHolder1_Label1');
//            alert(label);
            label.innerHTML = 'You hit cancel in the Confirm dialog on ' + (new Date()).localeFormat("T") + '.';
        }
    </script>

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <div>
                <asp:Button ID="Button1" runat="server" Text="Button" />
                <cc1:ConfirmButtonExtender ID="Button1_ConfirmButtonExtender" runat="server" ConfirmText="Are you sure to submit?"
                    Enabled="True" TargetControlID="Button1" OnClientCancel="confirmCancel">
                </cc1:ConfirmButtonExtender>
                <br />
                <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>

转载于:https://www.cnblogs.com/lx0831/archive/2009/01/05/1369313.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值