Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have 10 pages and each body tag has its own class because of different background images on them. I was wondering how to do it in the master master page so that the class on the body tag when a new page is created is correct.

share|improve this question
add comment

4 Answers

If I'm understanding your question correctly, you have 10 different types of pages in which the content area or body have specific classes depending on that content. A master page isn't going to get you the desired results. You'll want to have varying page layouts for that. Each page layout can have it's content area defined with your appropriate class so that you get the desired effect.

share|improve this answer
    
exactly sir the classes will be different layouts in every page –  user555600 Jul 21 '11 at 0:14
add comment

It sounds as though what you are trying to do is generate unique content on each page but do it through the master page.

This is the wrong approach. Use your master page for elements of your branding that are consistent across all your pages. Of course because of the position of the body tag in your page element hierarchy you can't have that defined in the page.aspx, so you will need to define your background image some other way. This is a question for a CSS expert, but I would suggest, in your master page, using a single class for your body element (if you need one at all), and associating the particular image with that class in the page.aspx file. This could be something like a STYLE element or a link to a particular small CSS stylesheet.

share|improve this answer
add comment

I suggest using the same class, but override it in the specific pages, i.e. give the body tag a classname, then in the pages themselves override say the background-image property of this class. Since CSS is cascading the last read value will be used.

share|improve this answer
add comment

use jquery:

var url = location.search;
if (url.indexOf('/page-1.aspx')>= 0) {
$('body').addClass('class1');   
}

http://api.jquery.com/addClass/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.