Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Programming UserControls
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01330659
Message ID:
01330683
Vues:
18
>>Hi everybody,
>>
>>Is it possible from inside the UserControl code behind to get a reference to the parent control (page, FormView, etc.)? Or this is impossible since we don't know in design time where the control is going to be placed?
>>
>>Thanks a lot in advance.
>>
>
>Yes, just use the Parent property. You can also get a reference to the Page via the Page property. If you have some custom and/or control interface or type you'll need to cast it to the correct type to access it's properties/methods.

Interesting. Does it mean I can do something like
FormView frmRegular = (FormView) this.Page.FindControl("myFormViewName")
if ...
Where can I use this type of the code? Is it possible in Load method?

I have GeneralInformation user control that contains gender among other controls. I want to be able to attach some client side logic to changing gender. So, I may add attribute in the Load method for onchange. I can also add some custom JavaScript function to our master.js file that would try to set custom JavaScript property for the custom autosuggestbox we're using.
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