当单选按钮客户端检查更改时使用 JQuery 调用函数

Call function using JQuery when radio button client side check chaged

我有 AutoPostBack="true" 的单选按钮,当客户端在回发前检查更改事件时,我想通过 JQuery 调用函数,例如 asp 按钮中的 OnClientClick

<asp:RadioButton ID="rdoptiontxt" runat="server" Text="Text Box"  AutoPostBack="true"
                GroupName="Qypye" oncheckedchanged="rdoptiontxt_CheckedChanged"/>

<asp:RadioButton ID="rdoptiontxtArea" runat="server" Text="Text Area"  AutoPostBack="true"
                GroupName="Qypye" oncheckedchanged="rdoptiontxtArea_CheckedChanged"/>  

删除 AutoPostBack 属性并使用 JavaScript 中的 __doPostBack() 调用回发。

<asp:RadioButton ID="rdoptiontxt" runat="server" Text="Text Box"  
            GroupName="Qypye" oncheckedchanged="rdoptiontxt_CheckedChanged" onclick="persistingTextBox(); "/>

<asp:RadioButton ID="rdoptiontxtArea" runat="server" Text="Text Area"  
            GroupName="Qypye" oncheckedchanged="rdoptiontxtArea_CheckedChanged" onclick="persistingTextBox(); "/> 

JavaScript

function persistingTextBox() {
        //Do whatever you want
        __doPostBack();
}