Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
User Control - raising an event
Message
General information
Forum:
ASP.NET
Category:
Other
Environment versions
OS:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01327983
Message ID:
01328072
Views:
14
This message has been marked as the solution to the initial question of the thread.
>
>Do you have samples or ideas how this should be done?
>

Just expose it as an event on the user control, then call that event from within the user control, ex.

In your user control:

- Create a new event that mimicks the current SelectedIndexChanged event of the control
- Create a OnSelectedIndexChanged method which will raise the event
- Hook up the SelectedIndexChanged handler like you normally would and have it call the OnSelectedIndexChanged method.

In your page which uses this user control:

- Hook up the event to your new SelectedIndexChange event on the user control.
// User Control
public event EventHandler SelectedIndexChanged;

public virtual void OnSelectedIndexChanged(object sender, EventArgs e)
{
    if (this.SelectedIndexChanged != null)
        this.SelectedIndexChanged(sender, e);
}

protected void cboList_SelectedIndexChanged(object sender, EventArgs e)
{
    this.OnSelectedIndexChanged(sender, e);
}
-Paul

RCS Solutions, Inc.
Blog
Twitter
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform