2015-10-14 68 views
1

我有单选按钮AutoPostBack="true",并希望在客户端检查更改事件之前调用函数由jQuery按钮回调如OnClientClick之前。单选按钮客户端检查更改时使用jQuery的调用函数

<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"/> 
+0

你应该包括这在以前的帖子为什么要创建一个新的?那么,如果在Radiobutton标记中包含'onclick',任何成功? – Prabhat

+0

使用'onclick'将停止Autopostback甚至返回'true' – Nishantha

+1

您可以使用'__doPostback(this,“”)'事件而不是返回true。如果条件失败,如果返回true,则执行'__doPostback()' – Prabhat

回答

0

删除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(); 
} 
+1

太棒了,你现在可以接受你自己的答案:) – Prabhat

+0

@Suprabhat哈哈:P – Nishantha

相关问题