从onClientClick转换到onClientClick

Converting from OnClientClicking to onClientClick

本文关键字:onClientClick 转换      更新时间:2023-09-26

我目前有一个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工作?onClientClick(Telerik)和onClientClick(asp)之间的区别是什么

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

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;" />

几天前我也遇到过这个问题。实际上Radbutton's默认设置为true为Autopostback,所以如果你想在Radbutton中实现这一点!然后,您需要更改回发属性(稍后可以在jscript中更改)以及causesvalidation检查。

<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>

和script

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