OnSelectedIndexChanged stopping form from displaying

ianmcinnes

Newcomer
Joined
Oct 13, 2005
Messages
2
Hi guys,

Hopefully someone can shed some light on this weird problem:

If have an .ascx with standard form controls in it, the section in question is:

...
<TR>
<TD>
<asp:Label id="LblVenueCounty" runat="server">Venue County</asp:Label>
</TD>
<TD>
<asp: DropDownList id="DDVenueCounty" runat="server" OnSelectedIndexChanged="PopulateTown" />
</TD>
</TR>
...

The form displays fine until I add "OnSelectedIndexChanged=PopulateTown" to 'DDVenueCounty'. As soon as I add this bit of code the entire form is not rendered. So the above example does not work, but this does:

...
<TR>
<TD>
<asp:Label id="LblVenueCounty" runat="server">Venue County</asp:Label>
</TD>
<TD>
<asp: DropDownList id="DDVenueCounty" runat="server" />
</TD>
</TR>
...

I have no code in the codebehind or anywhere else that could effect this (that I know of) - I have also tried creating the PopulateTown Sub just in case this was effecting it but this makes no difference. :confused:

Any help would be apprechiated, this makes no sense to me and I see no reason why the entire form is not displayed!

Thanks in advance

E
 
Last edited:
If the sub you wrote called PopulateTown isn't protected (private), then you will recieve an error. Notice in your second example you don't have the OnSelectedIndexChanged event in the attributes...thus no error. Rather than having OnSelectedIndexChanged in the html code you could just wire up the event in the code behind. The only time that I wire up events in the html is if the control is in a container that wouldn't fire child events normally (such as a datagrid).
 
Thanks bri189a,

I wouldnt mind if it gave me an error message - at least then I could start to work out what is going on!

All the examples I have found all show this should work without any problems.

I will try moving the OnSelectedIndexChanged to the code behind to see if that solves it. I'd rather keep it in the .ascx so if anyone else can see what's causing this please let me know!
 
Back
Top