Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have using nested master pages first one is baseMasterPage which is used by other master page called childMasterPage. Now I have content page called details which have using childMasterPage as a MasterPageFile. i have some value on lavel control on baseMasterPage and i want to access it on details page, But i am not able to do that. I am able to access it on childMasterPage by code--
Label lblWelcome =Master.FindControl("Label1") as Label;
Label2.Text = lblWelcome.Text.ToString();

but not on details page.Please tell me how i can access it on details page.
Posted

1 solution

This sounds like a nightmare. I never use FindControl, that's an ugly hack. I create my own base classes for my page that return strongly typed values for the MasterPage property. If you do that on both levels, then this.MasterPage.MasterPage will give you your class, where you should expose properties on your controls as needed, not the entire control.
 
Share this answer
 
Comments
ranjansingh235 8-Jul-10 4:43am    
thanks for your reply--

Can you explain how i can access value of a lavel control of baseMasterPage on details page.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900