I get an "The type 'System.Web.UI.UserControl' has no event

  • Thread starter Thread starter Michel
  • Start date Start date
M

Michel

Hi all,


I just created a new usercontrol, which basicly display's a
dropdowlist.
For this control, I created the a new SelectedIndexChanged event to
raise the SelectedIndexChanged event of the dropdowlist to the parent.

This all runs fine, but every time I open a page which contains my
control, I get an "The type 'System.Web.UI.UserControl' has no event
named 'SelectedIndexChanged'" on the line (in the parent) where I hook
the event :
this.mycontrol.SelectedIndexChanged += new
System.EventHandler(this.mycontrol_SelectedIndexChanged);

Anyone who has an idea why?


Thanks,

M.
 
Michel,

It looks like myControl is a reference to the base type, UserControl,
and not to your type. Otherwise, the error would give your type name. Are
you sure that you are trying to add the event handler to a reference of the
correct type?

Hope this helps.
 
Hi Nicholas,

I've been thinking about that too, but I have no idea what could be
wrong.

I dragged the control onto the page in the design, and added a
declaration for my web user control in the code behind :

protected MyControlDropDown mycontrol;

In the InitializeComponent I put the line on which he say's their is a
problem.

this.mycontrol.SelectedIndexChanged += new
System.EventHandler(this.mycontrol_SelectedIndexChanged);

The strange part is that I can run without a problem. Only when I open
the html page on which I put the control, I get this message.
 
Back
Top