Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
User Control - raising an event
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
OS:
Windows XP
Database:
MS SQL Server
Divers
Thread ID:
01327983
Message ID:
01328072
Vues:
15
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform