gpt4 book ai didi

javascript - 当页面无效时,asp.net 单选按钮不会回发

转载 作者:行者123 更新时间:2023-11-30 06:00:47 29 4
gpt4 key购买 nike

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

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com