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:
01328076
Vues:
19
>>
>>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);
>}
>
>
I need to study this more, it is not really simple for me now. Thanks again.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform