A
Andrew Jocelyn
Hi
I'm using VS2005 and AJAX extensions. The SelectedIndexChanged fires when I
select ListItem TextBox2 but does not fire when I select TextBox1
afterwards. If I remove Selected="True" from the ListItem for TextBox1 the
event fires as expected. I need to have a default selected on first page
load. How do I do this?
<asp:RadioButtonList ID="RadioButtonList1" runat="server"
RepeatDirection="Horizontal"
RepeatLayout="Flow"
OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"
AutoPostBack="true">
<asp:ListItem Selected="True">TextBox1</asp:ListItem>
<asp:ListItem>TextBox2</asp:ListItem>
</asp:RadioButtonList>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="RadioButtonList1"
EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
protected void RadioButtonList1_SelectedIndexChanged(object sender,
EventArgs e)
{
RadioButtonList radList = (RadioButtonList)sender;
if (radList.SelectedIndex == 0)
{
TextBox1.Visible = false;
TextBox2.Visible = true;
}
else
{
TextBox1.Visible = true;
TextBox2.Visible = false;
}
}
Thanks
Andrew
I'm using VS2005 and AJAX extensions. The SelectedIndexChanged fires when I
select ListItem TextBox2 but does not fire when I select TextBox1
afterwards. If I remove Selected="True" from the ListItem for TextBox1 the
event fires as expected. I need to have a default selected on first page
load. How do I do this?
<asp:RadioButtonList ID="RadioButtonList1" runat="server"
RepeatDirection="Horizontal"
RepeatLayout="Flow"
OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"
AutoPostBack="true">
<asp:ListItem Selected="True">TextBox1</asp:ListItem>
<asp:ListItem>TextBox2</asp:ListItem>
</asp:RadioButtonList>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="RadioButtonList1"
EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
protected void RadioButtonList1_SelectedIndexChanged(object sender,
EventArgs e)
{
RadioButtonList radList = (RadioButtonList)sender;
if (radList.SelectedIndex == 0)
{
TextBox1.Visible = false;
TextBox2.Visible = true;
}
else
{
TextBox1.Visible = true;
TextBox2.Visible = false;
}
}
Thanks
Andrew