ASP.NET DropDownList control doesn't postback correctly inside of UserControl
- by RichardAZ
I have a situation where a DropDownList control is not posting back correctly. The AutoPost property is set to true, so the postback does happen, but the SelectedValue is not set to the correct value. In addition, the onSelectedIndexChanged event doesn't fire. The exact same code works perfect fine on an ASPX page, but does not work in a ASCX control.
I have tried all the obvious things, I hope, trying to figure this one out, but no luck so far. I have even investigated what comes back in Request.Form["__EVENTTARGET"] and __EVENTARGUMENT. __EVENTTARGET does point to the drop down list, but the argument is empty.
Can the folks of StackOverflow help lead me in the right direction to debug this issue. Of course, it is further complicated by master pages and the usual overcomplication of ASP.NET. Here is the code:
<div>
<asp:DropDownList ID="testDrop" runat="server" AutoPostBack="true"
EnableViewState="true" onselectedindexchanged="testDrop_SelectedIndexChanged">
<asp:ListItem Value="1" Text="1">1</asp:ListItem>
<asp:ListItem Value="2" Text="2">2</asp:ListItem>
</asp:DropDownList>
</div>
And here is the generated html:
<select id="ctl00_MainContent_rptAccordion_ctl00_statControl_testDrop" onchange="javascript:setTimeout('__doPostBack(\'ctl00$MainContent$rptAccordion$ctl00$statControl$testDrop\',\'\')', 0)" name="ctl00$MainContent$rptAccordion$ctl00$statControl$testDrop">
<option value="1" selected="selected">1</option>
<option value="2">2</option>
THANKS!