在单选按钮中选择一个选项后,我在发回时遇到问题。选择“是”后,必须回传以加载下方的文本框;但是,如果选择否,则不得出现文本框。
我在我的网站http://www.codeproject.com/Articles/17571/Maintain-focus-between-postbacks-in-ASP-NET-2-0-al上找到了其他回发问题的解决方案(我添加了单选按钮“CurrentControl 是”的列表),但出于我自己以外的原因,它似乎不适用于单选按钮。
由于我刚刚创建了我的帐户,我还不能发布图片,但是当页面回传时,焦点会转移到最后一个文本框或下拉列表已经被关注。
单选按钮的 Aspx:
<table class="dataentry">
<tr>
<td class="column1">
<asp:Label ID="lblPrevEmployed" runat="server" Text="Have you ever been employed by our company?"meta:resourcekey="lblPrevEmployed"></asp:Label>
</td>
<td class="column2">
<asp:RadioButton ID="rdoPrevEmployed_Yes" runat="server" GroupName="PrevEmployed" AutoPostBack="True" OnCheckedChanged="rdoPrevEmployed_OnCheckedChanged" Text="Yes" meta:resourcekey="rbPrevEmployedYes" />
<asp:RadioButton ID="rdoPrevEmployed_No" runat="server" GroupName="PrevEmployed" AutoPostBack="True" OnCheckedChanged="rdoPrevEmployed_OnCheckedChanged" Text="No" meta:resourcekey="rbPrevEmployedNo" />
<asp:CustomValidator ID="cvPrevEmployed" runat="server" ErrorMessage="You must select either Yes or No." ValidationGroup="Group" OnServerValidate="cvPrevEmployed_ServerValidate" Display="Dynamic" meta:resourcekey="cvPrevEmployed"></asp:CustomValidator>
</td>
</tr>
</table>