C# 回发后单选按钮失去焦点

C# 回发后单选按钮失去焦点,c#,asp.net,focus,C#,Asp.net,Focus,在单选按钮中选择一个选项后,我遇到了发回的问题。 选择“是”后,必须发回以加载下面的文本框;但是,如果选择“否”,则文本框不得出现 我已经在网站上找到了其他回发问题的解决方案(我在“CurrentControl is”列表中添加了单选按钮),但出于我自己以外的原因,它似乎不适用于单选按钮 由于我刚刚创建了我的帐户,我还不能发布图片,但是当页面发回时,焦点会转移到最后一个已聚焦的文本框或下拉列表 Aspx用于单选按钮: <table class="dataentry"> &l

在单选按钮中选择一个选项后,我遇到了发回的问题。 选择“是”后,必须发回以加载下面的文本框;但是,如果选择“否”,则文本框不得出现

我已经在网站上找到了其他回发问题的解决方案(我在“CurrentControl is”列表中添加了单选按钮),但出于我自己以外的原因,它似乎不适用于单选按钮

由于我刚刚创建了我的帐户,我还不能发布图片,但是当页面发回时,焦点会转移到最后一个已聚焦的文本框或下拉列表

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" /> &nbsp;
               <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>

尝试以下方法: (我使用了RadioButton列表而不是单个RadioButton)

一个div用于单选按钮列表,第二个div用于显示与所选单选按钮关联的说明

此外,还将通过消息启用通知标签(默认情况下将禁用)

[HTML]

<asp:Label ID="NotifyLabel" runat="server" Text="" ForeColor="Red" Font-Bold="true"></asp:Label>
<br />
<div id="SelAccTypeSelect" runat="server" style="float: left; margin-right: 20px;">
<asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal" AutoPostBack="True" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
    <asp:ListItem Value="0" Text="Account Type 1" />
    <asp:ListItem Value="1" Text="Account Type 2" />
</asp:RadioButtonList>
</div>
<div id="SelAccTypeDesc" runat="server" style="width: 920px;"></div>


是一个数组,包含与单选按钮值相对应的可用描述

[代码隐藏]

private void InitializeSelAccTypeDesc()
{
SelAcctDescription[0] = "<p>This account type is for users who want to do something like this.</p>";
SelAcctDescription[1] = "<p>This account type is for other users who want to do something like that.</p>";
}

protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
// get the selected account type
AccTypeByte = Convert.ToByte(RadioButtonList1.SelectedValue.ToString());

      // notify the user with the value of the selected radio button
NotifyLabel.Visible = true;
NotifyLabel.Text = string.Format("{0} was the value selected.   -   ", AccTypeByte);

// replace the html in the div with the html from the selected array element
SelAccTypeDesc.InnerHtml = SelAcctDescription[Convert.ToInt32(AccTypeByte)];
}
private void初始化selacctypedesc()
{
SelAcctDescription[0]=“此帐户类型适用于希望执行类似操作的用户。

”; selactdescription[1]=“此帐户类型适用于希望执行类似操作的其他用户。

”; } 受保护的无效RadioButtonList1\u SelectedIndexChanged(对象发送方,事件参数e) { //获取所选帐户类型 AccTypeByte=Convert.ToByte(RadioButtonList1.SelectedValue.ToString()); //用所选单选按钮的值通知用户 NotifyLabel.Visible=true; NotifyLabel.Text=string.Format(“{0}是所选的值。-”,AccTypeByte); //将div中的html替换为所选数组元素中的html SelAccTypeDesc.InnerHtml=SelAcctDescription[Convert.ToInt32(AccTypeByte)]; }
*注意:0可以是“否”,1可以是“是”
您可以在NotifyLabel周围添加if语句,以便仅基于AccTypeByte的值显示。

是否有任何方法可以在上下文中查看您的代码?我觉得这可能适用于我正在做的事情,但我目前还不清楚背后的代码对焦点真正做了什么。谢谢你的回复!