<asp:RadioButton ID="rdoComm" runat="server" Text="Business Investment" AutoPostBack="true"
GroupName="selectionType" OnCheckedChanged="rdoComm_CheckedChanged" />
<asp:RadioButton ID="rdoRes" runat="server" Text="Real Estate" GroupName="selectionType"
AutoPostBack="true" OnCheckedChanged="rdoRes_CheckedChanged" />
<asp:RadioButton ID="rdoBoth" runat="server" Text="Both" GroupName="selectionType"
AutoPostBack="true" OnCheckedChanged="rdoBoth_CheckedChanged" />
每当我使用“Page_ClientValidate('group')”强制验证时,单选按钮不会回发,但是如果我不使用我提到的方法并将其留给 asp.net 验证,即使页面无效单选按钮仍然回传。
单选按钮不是用于回发,而是用于隐藏和显示页面上的控件。
有什么想法吗?>?
最佳答案
您应该转向基于 javascript 的解决方案...这将避免回发并为用户提供更好的体验。
但如果你不能,只需设置 CausesValidation
property单选按钮上的 false
:
<asp:RadioButton ID="rdoComm" runat="server" Text="Business Investment" AutoPostBack="true" CausesValidation="false"
GroupName="selectionType" OnCheckedChanged="rdoComm_CheckedChanged" />
<asp:RadioButton ID="rdoRes" runat="server" Text="Real Estate" GroupName="selectionType" CausesValidation="false"
AutoPostBack="true" OnCheckedChanged="rdoRes_CheckedChanged" />
<asp:RadioButton ID="rdoBoth" runat="server" Text="Both" GroupName="selectionType"
AutoPostBack="true" CausesValidation="false" OnCheckedChanged="rdoBoth_CheckedChanged" />
关于javascript - 当页面无效时,asp.net 单选按钮不会回发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8720413/