从OnClientClicking转换为onClientClick

时间:2015-07-07 10:19:33

标签: javascript c# asp.net telerik

我目前有一个JavaScript方法,可以查看页面是否经过验证,如果允许用户按下创建按钮并抛出radconfirm,我遇到的问题是,如果我使用radButton这完美但当使用ASP:Button时,它不会让radConfirm出现并跳过它。

这是方法:

function ShowConfirm(clickedButton, args) {

        var validated = window.Page_ClientValidate('POPgroup');

        if (validated) 
        {
            args.set_cancel(true);

            function confirmCallBackFn(arg) {
                if (arg == true) {
                    clickedButton.click();
                }
            }
            var text = "Please make sure all fields are completed correctly as once" +
                    " accepted the proof of purchase will be submitted and no further " +
                    "changes will be allowed. Are you sure you wish to continue?";
            radconfirm(text, confirmCallBackFn,350,100,null,"Confirm");
            }
        }

这是按钮:

 <asp:Button ID="AddProofOfPurchaseButton" runat="server" Text="Submit" 
ValidationGroup="POPgroup" CssClass="claim_header_create_button" 
OnClick="AddProofOfPurchaseButton_OnClick" OnClientClick="ShowConfirm(this); 
 return false;" />

我如何更改此代码以使用asp按钮而不是radbutton?为什么会发生这种情况OnClientClicking(Telerik)与onClientClick(asp)之间的区别

2 个答案:

答案 0 :(得分:0)

对于遇到同样问题的其他人,我发现问题的答案就是这个。

function ShowConfirm(button) {

        var validated = window.Page_ClientValidate('POPgroup');

        if (validated) {

            function CallbackFn(arg) {
                if (arg) {
                    __doPostBack(button.name, "");
                }
            }
            var text = "Please make sure all fields are completed correctly as once" +
                    " accepted the proof of purchase will be submitted and no further " +
                    "changes will be allowed. Are you sure you wish to continue?";
            radconfirm(text, CallbackFn, 350, 100, null, "Confirm");
        }
    }

按钮就像这样:

 <asp:Button ID="AddProofOfPurchaseButton" runat="server" Text="Submit"
 ValidationGroup="POPgroup" CssClass="claim_header_create_button"
 OnClick="AddProofOfPurchaseButton_OnClick" OnClientClick="ShowConfirm(this); return false;" />

答案 1 :(得分:0)

几天前我也遇到了这个问题。实际上,默认情况下, Radbutton 的设置为 true ,因此如果你想在 radbutton 中实现这一点!然后, 您需要更改回发属性(您可以稍后在jscript中更改它)以及 causevalidation 检查。

<telerik:RadButton ID="AddProofOfPurchaseButton" Text="Submit" CssClass="claim_header_create_button" runat="server" 
ValidationGroup="POPgroup" OnClientClicking="ShowConfirm" CausesValidation="false" AutoPostBack="false" OnClick="AddProofOfPurchaseButton_OnClick"></telerik:RadButton>

以及脚本

function confirmCallBackFn(arg) {
if (arg == true) {
clickedButton.set_autoPostBack(true);   //removed -->clickedButton.click();   
}  else { clickedButton.set_autoPostBack(false); }