我有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();
}
关于javascript - 当单选按钮客户端检查更改时使用 JQuery 调用函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33117120/