mix2.gif
 Home   Utilities   Purchase   FAQ   Contact     
 
Shareware Utilities
Freeware Utilities
Miscellaneous
clipchk.gif BPSoftware Blog
clipchk.gif Swansea Police Dispatch Log
clipchk.gif Farmville Table
clipchk.gif Purchase Shareware
clipchk.gif Contact


Saturday, September 19, 2009
Update a control on a Master Page

Creating a Master Page in Visual Studio makes simplifies the development of ASP.NET websites. Master Page's allow for the creation of consistent and standard layouts (template) for a group of pages or an entire website. ContentPlaceHolders are used to designate where on a page based on a Master Page will have variable content. Sometimes it may be necessary to update a control that is part of the Master Page, rather within the ContentPlaceHolder area. There are several ways to update a control on a Master Page. A page's Master property allows for access to a page’s Master Page content. The following code is one example of how to update a control on a master page. The code would be run from the page based on a Master Page.

Image MasterLogo = (Image) Master.FindControl ( "Logo" );
if ( MasterLogo != null )
{
MasterLogo.ImageUrl
= "~/images/logo.gif";
}

Label MasterLabel
= (Label) Master.FindControl ( "Label1" );
if ( MasterLabel != null )
{
MasterLabel.Text
= "Set from page";
}

Labels: ,

posted by Brad Prendergast at 10:49:00 PM
Comments:
Links to this post:

Create a Link

Recent Posts


Archives