Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Subclassing - i am getting better at this more help tho
Message
De
13/07/2004 12:22:37
 
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
00923810
Message ID:
00923823
Vues:
16
Shawn,

>The question i have is why is it running that code in the first place i put code on my button, this code should override the base class code shouldn't it.
>
>I tried adding override to the button but i get and error.
>
>Considering the button is declared as private, then it should only run my code right?


As I think I mentioned to you before, EventHandlers work a bit different than methods when overriding things. You can't override the Click EventHandler in your base button. You can sub-class this button and put in another Click EventHandler, as you've done, but the base class's Click EventHandler will always fire first, before the sub-classes Click EventHandler. If you need different behavior in the Click of a button, you're better off creating your own event and raising that event in the base button's click. Then, your sub-classed button can be listening for your own event instead of the Click event. Is this clearer or is it still confusing?

BTW, I'm still hoping that someone with MM knowledge will help you here. I have no way of knowing anything about the MM base classes and I'm just trying to answer in generic terms.

~~Bonnie


>I have a button that has a click event that calls a method called AuthenticateUser()
>
>
>private void btnOK_Click(object sender, System.EventArgs e)
>{
>	this.AuthenticateUser();
>}
>
>
>I subclassed this button.
>
>On my button in the click event I put this code.
>
>public void btnOK_Click(object sender, System.EventArgs e)
>{
>	bool lResult = this.Login_Click();
>	if (!lResult)
>		this.txtCompanyID.Focus();
>}
>
>when I run the form it runs the authenticateUserCode and then it runs my code.
>
>the only way to stop this was to add the following code
>
>protected override void AuthenticateUser()
>{
>}
>
>
>Now it appears to only run my code.
>
>The question i have is why is it running that code in the first place i put code on my button, this code should override the base class code shouldn't it.
>
>I tried adding override to the button but i get and error.
>
>Considering the button is declared as private, then it should only run my code right?
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform