单选按钮列表 页面的选择和回发
本文关键字:选择 列表 单选按钮 | 更新日期: 2023-09-27 18:36:37
在我的程序中,我使用了更新面板和脚本管理器。我的问题是,我正在使用名为 RbFresh 的单选按钮,当我选择"经验丰富"时,它有两个名为"新鲜"和"经验"的值,我将在此面板上显示一个面板,我已放置文本框控件。但是选择后,radionbutton总页面中的任何值都将是完整的回发。如何避免我的页面完全回发。
<asp:UpdatePanel ID="UpdatePanel4" runat="server">
<ContentTemplate>
<asp:RadioButtonList ID="RbFresh" runat="server" onselectedindexchanged="RbFresh_SelectedIndexChanged"
RepeatDirection="Horizontal" Width="297px" AutoPostBack="True">
<asp:ListItem Text="Fresher" Value="1"></asp:ListItem>
<asp:ListItem Text="Experienced" Value="2"></asp:ListItem>
</asp:RadioButtonList>
</ContentTemplate>
</asp:UpdatePanel>
<Triggers>
<asp:PostBackTrigger ControlID="Rbfresh"/>
</Triggers>
使用此代码页将不会回发,您可以轻松获取单选按钮的值
粘贴到网页上
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel4" runat="server">
<ContentTemplate>
<asp:RadioButtonList ID="RbFresh" runat="server" onselectedindexchanged="RbFresh_SelectedIndexChanged"
RepeatDirection="Horizontal" Width="297px" AutoPostBack="True">
<asp:ListItem Text="Fresher" Value="1"></asp:ListItem>
<asp:ListItem Text="Experienced" Value="2"></asp:ListItem>
</asp:RadioButtonList>
</ContentTemplate>
</asp:UpdatePanel>
粘贴到.cs页面上
protected void RbFresh_SelectedIndexChanged(object sender, EventArgs e)
{
int Value = 0; int.TryParse( RbFresh.SelectedValue,out Value);
int ID = Value;
}