views:

1082

answers:

4

Asp.Net 2.0 framewrok - VB.Net application I have a UserControl containing a Asp.Net DropDownList.

Things already researched and \ or tried:

  • The control gets bound to data on page load inside if not Page.IsPostBack (only loads once)
  • ID proprety is set for control (ID = ddlMyControl)
  • AutoPostBack is set to true
  • EnableViewState on the control is set to true
  • AutoEventWireUp in the UserControl declaration is set to true
  • EnableEventValidation is set to false in the parent page

The control will not fire it's SelectedIndexChanged event no matter what I do. HELP !!

Thanks :)

A: 

What about the "surounding" page. You could try your UserControl within another page?

How do you add the event handler? How do you include the use control? (When via code, may be to late?)

May be you could show some code ;-)

Robert
Added code in an answer above so that I could use a code block.
Jim Evans
A: 

The UserControl is not being loaded dynamicaly but added to the parent page at design time in the HTML of the page

<uc3:TheControl ID="ucMyControl" runat="server" />

The event handler is codded in the code behind of the UserContorl itself - standard stuff:

 Protected Sub ddlMyThing_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlMyThing.SelectedIndexChanged
    'Do event stuff here.
End Sub
Jim Evans
It would be better to extend the original question instead to make it an communication thread - I believe..
Robert
Does the autoPostBack work, so does the page reload?
Robert
No - the autopostback is not firing at all - I set breakpoints in debug on both the page load and also in the SelectIndexChanged event handler and the app just flys right by without stopping when I select a new item in the DropDownList. Button clicks in the same usercontrol DO fire however - now go figure :)
Jim Evans
I'm not sure what you mean by extending the question to a communication thread - but if you tell me how....
Jim Evans
Do you have an Javascript error?
Robert
No Javascript error
Jim Evans
Actually - there seems to be a javascript error on the page:this.getelement().style is null or not setAfter googling that a lot it seems to be related to the Asp.Net AJAX Toolkit - which is in use here. But found no resolution.
Jim Evans
A: 

Have you set the onselectedindexchanged="ddlMyThing_SelectedIndexChanged" property of the ddl?

Ahmad
No - there is a handles attribute on the event handler Protected Sub ddlMyThing_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlMyThing.SelectedIndexChanged 'Do event stuff here. End Sub
Jim Evans
A: 

I think you need to set EnableEventValidation to True.

Check this out.

http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_22405007.html

Hope this helps.

Thanks,

Raja

Raja
I will not pay that site for an answer :) - that being said - EnableEventValidation is true by default if not declared and the postback was not wroking. One of the articles I found in my research had a resolution to the exact same problem by setting it to false - did not work for me though.
Jim Evans