M
Michael Conroy
Slap a radiobuttonlist on the screen with a textbox and a button. Change the
order of the RBL and textbox and suddenly viewstate and event handling goes
away. Swap 'em back and all is well. This ready to run code snippet
demonstrates the behavior.
Does ANYBODY have any idea why this is...and more importantly, what I can do
about it? Is this a bug, my own lack of sleep, or a "forest for the trees"
problem.
Cheers,
M.
<%@ Page Language="C#" EnableSessionState="True" Trace="True" %>
<HTML>
<HEAD>
<script runat="Server" language="C#">
protected void Page_Load(object sender, System.EventArgs e)
{
this.m_rbList.SelectedIndexChanged += new
System.EventHandler(this.m_rbList_SelectedIndexChanged);
if(!this.IsPostBack)
{
for(int i=0;i<5;i++)
{
m_rbList.Items.Add("Choice " + i.ToString());
}
}
}
private void m_rbList_SelectedIndexChanged(object sender,
System.EventArgs e)
{
if(m_rbList.SelectedIndex>-1)
this.m_btnNext.Enabled=true;
else
this.m_btnNext.Enabled=false;
}
</script>
</HEAD>
<body style="FONT: 10pt verdana">
<form runat="Server" id="Form1">
<!-- THIS WORKS
<asp:RadioButtonList id="Xm_rbList" runat="server"
AutoPostBack="True"></asp:RadioButtonList>
<asp:Textbox value="TextBox/RadioButton Mystery"
id="XtxtName" runat="Server" ></asp:Textbox> -->
<!-- THIS DOESN'T!!!!!
<asp:Textbox value="TextBox/RadioButton Mystery"
id="ytxtName" runat="Server" ></asp:Textbox>
<asp:RadioButtonList id="ym_rbList" runat="server"
AutoPostBack="True"></asp:RadioButtonList> -->
<asp:Button id="m_btnNext" runat="server" Text="Next"
Enabled="False"></asp:Button></P>
<asp:RadioButtonList id="m_rbList" runat="server"
AutoPostBack="True"></asp:RadioButtonList>
<asp:Textbox value="TextBox/RadioButton Mystery"
id="txtName" runat="Server" ></asp:Textbox>
</FORM>
</body>
</HTML>
order of the RBL and textbox and suddenly viewstate and event handling goes
away. Swap 'em back and all is well. This ready to run code snippet
demonstrates the behavior.
Does ANYBODY have any idea why this is...and more importantly, what I can do
about it? Is this a bug, my own lack of sleep, or a "forest for the trees"
problem.
Cheers,
M.
<%@ Page Language="C#" EnableSessionState="True" Trace="True" %>
<HTML>
<HEAD>
<script runat="Server" language="C#">
protected void Page_Load(object sender, System.EventArgs e)
{
this.m_rbList.SelectedIndexChanged += new
System.EventHandler(this.m_rbList_SelectedIndexChanged);
if(!this.IsPostBack)
{
for(int i=0;i<5;i++)
{
m_rbList.Items.Add("Choice " + i.ToString());
}
}
}
private void m_rbList_SelectedIndexChanged(object sender,
System.EventArgs e)
{
if(m_rbList.SelectedIndex>-1)
this.m_btnNext.Enabled=true;
else
this.m_btnNext.Enabled=false;
}
</script>
</HEAD>
<body style="FONT: 10pt verdana">
<form runat="Server" id="Form1">
<!-- THIS WORKS
<asp:RadioButtonList id="Xm_rbList" runat="server"
AutoPostBack="True"></asp:RadioButtonList>
<asp:Textbox value="TextBox/RadioButton Mystery"
id="XtxtName" runat="Server" ></asp:Textbox> -->
<!-- THIS DOESN'T!!!!!
<asp:Textbox value="TextBox/RadioButton Mystery"
id="ytxtName" runat="Server" ></asp:Textbox>
<asp:RadioButtonList id="ym_rbList" runat="server"
AutoPostBack="True"></asp:RadioButtonList> -->
<asp:Button id="m_btnNext" runat="server" Text="Next"
Enabled="False"></asp:Button></P>
<asp:RadioButtonList id="m_rbList" runat="server"
AutoPostBack="True"></asp:RadioButtonList>
<asp:Textbox value="TextBox/RadioButton Mystery"
id="txtName" runat="Server" ></asp:Textbox>
</FORM>
</body>
</HTML>