1

I'm currently working on several custom ASPX server controls. Of course these controls do also expose events. Now one possibility is to register a handler in the code, more specifically in the page where the custom server control resides...like

protected void Page_Load(object sender, EventArgs e)
{
   myCustomControl.Click += new ....
}

But how do I have to expose the event in my server control code s.t. I can declare these event handlers directly on the ASPX code (from the Property Editor), similar as you can do it on the Button's click event??

Thanks a lot,

Juri

3 Answers 3

4

You do just that...

If you have a public event on your ASCX Control called PropertyChanged

then it'll be available declaritively on your Control as OnPropertyChanged

<ctl:MyControl ID="abc" runat="server" OnPropertyChanged="abc_PropertyChanged" />
Sign up to request clarification or add additional context in comments.

3 Comments

I'm working on SERVER CONTROLS. I guess you intend user controls since you mentioned ASCX :) There it works perfectly, thanks anyway
The principal is the Same for both custom server & ascx controls though. Expose your event publically, and then declaritively set the eventHandler to your method signature in the ASPX file
It works now, apparently there have been some other problems. However the event is not visible on the Properties editor on Visual Studio. Any hint on how to solve that?
0

Have you tried just making them public events?

Comments

0

This MSDN article does a good job explaining how to do this unfortunately it is more complicated than it seems like it should be.

[1]: http://msdn.microsoft.com/en-us/library/aa719907(VS.71).aspx/".NET Framework Developer's Guide"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.