Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What is better?
Message
 
 
À
07/04/2008 22:33:43
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Versions des environnements
OS:
Windows XP
Database:
MS SQL Server
Divers
Thread ID:
01308825
Message ID:
01308917
Vues:
10
Hi Bonnie,

To be more precise in my question, let me explain exactly what I wanted to accomplish and may be you suggest some approach (though it's ASP.NET question, but general principles should apply).

I want to highlight a grid record when I mouse over it and remove highlight with mouse out.

The website uses mostly controls right from the Toolbox (no custom controls).

For the particular page I was working on I have two grids. In one grid I added necessary functionality in RowCreated method. In another grid I just called the same Event Handler grdDeleteUser_RowCreated().

However, this doesn't look entirely kosher to me... I'd rather have both different handlers call custom function.

Or, may be even better, have a generic GridView class that have this functionality programmed and other properties set.

>It depends on what you're actually trying to do, as Viv mentioned, it may not be too clear from your description of what you're trying to accomplish.
>
>>Is it ok from one control event call another control's event or it's better to have both call their own but reference an extra common function?
>
>When I first read your question, it sounded like you wanted code in one control's event handler to call the event handler of another control. Something like this:
>
>
>private void MyTextBoxOne_Validated(object sender, System.EventArgs e)
>{
>	this.MyTextBoxTwo_Validated(sender, e);
>	// Maybe do some other stuff
>}
>private void MyTextBoxTwo_Validated(object sender, System.EventArgs e)
>{
>	// Do some stuff
>}
>
>
>This is obviously a no-no and I think Al thought your question was this, hence his answer.
>
>But, then, in your reply to Viv:
>
>>Or how would you approach the problem of having same code executed for the same event in different objects?
>
>It seems to me what you're actually asking is not what it seemed from your first question. Anyway, there's nothing wrong with having one event handler take care of an event for more than one control. Say I have several TextBoxes on my Form, but in the Validated event of each one, I want to do the exact same thing.
>
>So, I'd have one MyTextBoxValidatedHandler, and each TextBox would have a delegate for that event handler. Something like this:
>
>
>this.MyTextBoxOne.Validated()   += new EventHandler(this.MyTextBoxValidatedHandler);
>this.MyTextBoxTwo.Validated()   += new EventHandler(this.MyTextBoxValidatedHandler);
>this.MyTextBoxThree.Validated() += new EventHandler(this.MyTextBoxValidatedHandler);
>
>
>And the event handler would be the usual:
>
>
>private void MyTextBoxValidatedHandler(object sender, System.EventArgs e)
>{
>	// Do some stuff
>}
>
>
>HTH,
>~~Bonnie
If it's not broken, fix it until it is.


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

Click here to load this message in the networking platform