0
我想关注导致在asp.net radiobuttonlist中回发的相同ListItem。但是目前开发的实现只关注第一个列表项。有没有办法专注于导致回发的特定listitem?我无法在我的情况下使用更新面板。我的HTML代码隐藏和是如下:在ASP.NET WebForm中回传后重点放在RadioButtonList中的ListItem
HTML
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lblName" runat="server" Text="Name" AssociatedControlID="txtName"></asp:Label>
<asp:TextBox ID="txtName" runat="server" Text="Enter your name"></asp:TextBox>
<br />
<br />
<asp:Label ID="lblPersonType" AssociatedControlID="rdoPersonType" runat="server" Text="Person Type"></asp:Label>
<br />
<asp:RadioButtonList ID="rdoPersonType" RepeatLayout="Flow" AutoPostBack="true" runat="server" OnSelectedIndexChanged="rboPersonType_Selected"></asp:RadioButtonList>
</div>
</form>
</body>
</html>
代码隐藏
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
rdoPersonType.Items.Add(new ListItem() { Text = "Student", Value = "1", Selected = true });
rdoPersonType.Items.Add(new ListItem() { Text = "Greencard Holder", Value = "2" });
rdoPersonType.Items.Add(new ListItem() { Text = "Refugee", Value = "3" });
rdoPersonType.Items.Add(new ListItem() { Text = "Asylum", Value = "4" });
}
}
protected void rboPersonType_Selected(object sender, EventArgs e)
{
rdoPersonType.Focus();
}