Casting a Variable to User control

P

Peter Bucher [MVP]

Hello Dinu
How to Cast a Variable to User control in ASP.NET using vb.net as code-
behind

Dim myUserControl As UserControl = DirectCast(<var>, UserControl)
 
D

Dinu

Hi Peter,

Can u tell me how can we dynamically access properties of a user
control
in master page from a content page and set properties of user control
in master page from content page


thanks
 
P

Peter Bucher [MVP]

Hi Dinu
Can u tell me how can we dynamically access properties of a user
control
in master page from a content page and set properties of user control
in master page from content page
Access the masterpage in a contentpage with this.Master.Page, use further
the .FindControl() methode
of the masterpage to find the usercontrol. (Or use .FindControl twice, for
the ContainerControl in the masterpage AND then for the specific usercontrol
within the container.
then cast the usercontrol (Control) to (UserControl) and access the
properties you want.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top