Accessing controls on a masterpage

Here are a couple of neat things in ASP.NET 2.0 that I've used recently.

  • Access the controls on a master page. You'd think it must be possible, and it is, it's easy to do.
    Label Label1 = (Label)Master.FindControl("Label1");
    Label1.Text = "Set by child page";
  • ObjectDataSource...Before I used it I was suspecting that it may have been like one of the adapters in 1.1 which I try to keep away from on a the page itself. I find it cleaner to put all the database access logic in a datalayer under the business objects. Well it seems Microsoft may have been thinking the same thing! I can say nothing else but 'wow' to this control. This little component will bind just about anything including all the business objects that you've written. If you're not familiar with it, or have been avoiding it, it's worth checking out.
General .NET Code Snippets
Posted by: Brendan Kowitz
Last revised: 21 Sep 2013 12:15PM

Comments

8/5/2006 12:10:51 AM
I developed a nice techique for accessing Master Page control which you may find useful. I explained its use for accessing an Atlas ScriptManager, but it can be used for any control.

http://forums.asp.net/thread/1339455.aspx

1/8/2009 9:15:29 PM
excelent, thanks a lot. It is completely functional

No new comments are allowed on this post.