Search code examples
asp.netcustom-server-controls

Custom server control: specifying event declaratively on ASPX code


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


Solution

  • 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" />