Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to reference a control in user control?
Message
De
04/02/2010 10:42:39
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Versions des environnements
Environment:
C# 2.0
Divers
Thread ID:
01447396
Message ID:
01447495
Vues:
23
Dmitry,

>does it mean that I have to subclass this control and create it in code in a .CS file?

No, not at all. You already have the .cs file where you will put your code. When you created your UserControl, the IDE generates the MyUserControl.Designer.cs, but you also have the MyUserControl.cs ... it is in *this* file where you add any code you wish to give your class more funtionality. This is where you'd put additional methods and other member variables.

~~Bonnie




>>Dmitry, I wouldn't expose the properties of your UserControl publicly unless you really needed to. If all you need to do is DataBind the controls that are in your UserControl, do it by adding a DataBind method to your UserControl and pass in the DataTable as a parameter.
>>
>>~~Bonnie
>
>Thank you, Bonnie. If I were to add a method to UserControl, does it mean that I have to subclass this control and create it in code in a .CS file? Currently I create a UserControl by - in designer - adding a new UserControl. Then I drop some other controls on this user control form (like textbox, button). I can't think of how in this scenario I would add a method to the UserControl. Am I missing something simple?
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