Why no events showing for usercontrol

  • Thread starter Thread starter Lloyd Sheen
  • Start date Start date
L

Lloyd Sheen

I have a user control with two events. I drag it on the page I want to use
it. No problem. Execute to show the page and it renders correctly. So far
so good.

Now back to designer. Click on usercontrol and show properties. There are
none other than default usercontrol properties, again so far so good. There
is no events button on the properties window???

Now I double-click the usercontrol and am taken to code with the load event
of the usercontrol. While not what I wanted I am getting close. I pick the
usercontrol in the dropdown list of controls , and in the dropdown list of
events there are my events.


WHY IS THIS??? It seems that if you don't know how to manipulate VS 2005
Pro to get what you want it won't give it up very easily.


LLoyd Sheen
 
You need to check that the event is public and you may need to add an
attribute to the event in the user control.

e.g. (C#)

[
Category("Action"),
Description("Event Description")
]

There is also attribute that defines if the event is available in the
designer, although I think it is by default. Another attribute that
you put on the usercontrol class defines what the default event is
(the one added when you double click the control).

Failing all that, override oninit() in the page code and manually add
the event.

e.g. uiMyControl.DoSomething += new EventHandler ........
 
Back
Top