Telerik的:与RadButton preventing回传确认对话框 [英] Telerik : preventing postback with RadButton confirm dialog

查看:323
本文介绍了Telerik的:与RadButton preventing回传确认对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法落实确认对话框询问用户确认他的选择删除。如果用户点击取消RadButton不应回发到服务器。在确认对话框绝不会显示,我究竟做错了什么?

 <脚本类型=文/ JavaScript的>
    功能confirmAspButton(按钮){
        功能aspButtonCallbackFn(ARG){
            如果(ARG){
                __doPostBack(button.name,);
            }
        }
        radconfirm(你确定要删除?,aspButtonCallbackFn,330,110,空,确认);
    }
< / SCRIPT>
< Telerik的:RadButton
    ID =btnDeleteLines
    =服务器
    OnClientClicking =confirmAspButton(本);返回false;
    的OnClick =btnDeleteLines_Click
    文本=删除线(S)
    的AutoPostBack =假
    组名=GroupName1>
< / Telerik的:RadButton>


解决方案

好吧,我发现上的 Telerik的的网站,在 CustomRadWindowConfirm

 <脚本类型=文/ JavaScript的>
    //自定义RadWindow确认
    功能CustomRadWindowConfirm(发件人,参数)
    {
        //打开窗户
        找到$(<%= confirmWindow.ClientID%GT;)。展();
        //重点是按钮
        找到$(<%= btnYes.ClientID%GT;)。重点();
        //取消,回传
        args.set_cancel(真);
    }
    功能YesOrNoClicked(发件人,参数)
    {
        VAR oWnd = $找到(<%= confirmWindow.ClientID%GT;);
        oWnd.close();
        如果(sender.get_text()==是)
        {
            找到$(<%= btnDeleteLines.ClientID%GT;)。点击();
        }
    }
< / SCRIPT>
< Telerik的:RadButton
    ID =btnDeleteLines
    =服务器
    OnClientClicking =CustomRadWindowConfirm
    的OnClick =btnDeleteLines_Click
    文本=删除线(S)
    的AutoPostBack =假
    组名=GroupName1>
< / Telerik的:RadButton>

I am having trouble to implement the confirm dialog to ask the user to confirm his choice to delete. The RadButton should not postback to the server if the user clicks cancel. The confirm dialog never shows, what am I doing wrong?

<script type="text/javascript">
    function confirmAspButton(button) {
        function aspButtonCallbackFn(arg) {
            if (arg) {
                __doPostBack(button.name, "");
            }
        }
        radconfirm("Are you sure you want to delete?", aspButtonCallbackFn, 330, 110, null, "Confirm");
    }
</script>


<telerik:RadButton
    ID="btnDeleteLines" 
    runat="server" 
    OnClientClicking="confirmAspButton(this); return false;"
    OnClick="btnDeleteLines_Click"
    Text="Delete line(s)"
    AutoPostBack="false"
    GroupName="GroupName1">
</telerik:RadButton>

解决方案

Ok, I found out a way described on the telerik website, the CustomRadWindowConfirm.

<script type="text/javascript">
    //Custom RadWindow Confirm
    function CustomRadWindowConfirm(sender, args)
    {
        //Open the window
        $find("<%= confirmWindow.ClientID %>").show();
        //Focus the Yes button
        $find("<%= btnYes.ClientID %>").focus();
        //Cancel the postback
        args.set_cancel(true);
    }
    function YesOrNoClicked(sender, args)
    {
        var oWnd = $find("<%= confirmWindow.ClientID %>");
        oWnd.close();
        if (sender.get_text() == "Yes")
        {
            $find("<%= btnDeleteLines.ClientID %>").click();
        }
    }
</script>


<telerik:RadButton
    ID="btnDeleteLines" 
    runat="server" 
    OnClientClicking="CustomRadWindowConfirm"
    OnClick="btnDeleteLines_Click"
    Text="Delete line(s)"
    AutoPostBack="false"
    GroupName="GroupName1">
</telerik:RadButton>

这篇关于Telerik的:与RadButton preventing回传确认对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆