Change Property on Master Page at runtime?

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!
 
G

Guest

Hi David,
Every page has a "Master" property. You can use this property to change the
contents of master page.
 
D

David Lozzi

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
 
C

clintonG

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";
 
D

David Lozzi

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
 

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

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,216
Latest member
topweb3twitterchannels

Latest Threads

Top