Change Property on Master Page at runtime?

  • Thread starter Thread starter David Lozzi
  • Start date Start date
D

David Lozzi

Howdy,

I have my master page, and I would like to change the background CSS class
per the content page. Only the home page has a different background style,
all other pages are using the same. I know I can create a new master page,
but I'd like to just change the master page from the content page if
possible.

thanks!
 
Hi David,
Every page has a "Master" property. You can use this property to change the
contents of master page.
 
how to I select the class of the body? Also, would it make sense to check it
from the master page instead of per content page? So put this on the master
page

If content.Page.ToString = "ASP.default_aspx" then
use one background
else
use other
end if

just how do i get to the backjground properties or class name of body??

Thanks!!

David Lozzi
 
To reference properties of the master page from a content page we must type
the master in the content page from which we make the reference...

// in content page
<%@ MasterType VirtualPath="~/Masters/ThreeStackedPanels.master" %>
Then we can use public properties or the FindControl method to reference
properties of a control


// control in Master Page
LinkButton navigation = Master.Page.FindControl("NavigationLinkButton") as
LinkButton;
navigation.CssClass = "SmokeyBlue";
 
got it!
thanks

If cphBody.Page.ToString = "ASP.default_aspx" Then

bdBody.Style("background-image") = "url(site_images/bg_home.gif)"

Else

bdBody.Style("background-image") = "url(site_images/bg_second.gif)"

End If
 
Back
Top