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 hope you can help me with this simple user case.

I have a master page and several page layouts in SharePoint 2010. The master page standardizes only the header, navigation and footer. The page layout has a two column structure (a side bar and a main content section).

I need to add a fixed content to the side bar which won't be changed often (e.g. a small picture, static list) so this content applies to all page layouts. I can't add this content as a web part to every page in the site which are quite many and I don't want the user to be able to edit it anyway. And since the master page contains only the header and footer, I can't add this as a static web part to the master page as well. So I'm thinking of adding this fixed content to the page layouts in the code itself.

But I'm considering for future if later I want to edit this content, I will have to go and edit all page layouts which are around 40 custom page layouts (it's a multilingual site). Is there any simpler way to do this?

I have a background in PHP, in PHP I'd just create a file called "sidebar.php" and include it in every page layout, so in future I can just edit that file to implement any changes. Is there something similar in ASP/SharePoint?

Thank you very much.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

The closest thing to a php include is the ASP.NET concept of a user control http://msdn.microsoft.com/en-us/library/y6wb1a0e.aspx. Basically it's a snippet of html and codebehind that you can add to any number of pages.

However, if you're going to be adding the control to 40 page layouts, I'm not sure why you woudn't want to add it to the master. If you have other pages that don't use this element, hide it via css. You can add a specific class to the html element of all your pages that do include it and then show it only on those pages with a rule like "html.className elementName"

Also, I'm curious as to why the multilingual requirements are introducing 40 layouts. That seems excessive, even for a multilingual site.

share|improve this answer
    
Thank you for the info Andrew. I think User Controls are the answer. –  Ahmed Jabar Nov 5 '11 at 9:58

As explained by Andrew this could be achieved by adding a dot net user control.

You had also mentioned that you cant add this as a web part in the master page. Here is a link which could help you add a webpart in the master page following some simple steps - http://www.sharepointkings.com/2009/09/add-web-part-inside-master-page-in-moss.html

You can also think about making the webpart or the usercontrol reading data from a sharepoint list so that whenever you need to change the contents, you just change the list data. In this case you dont have to rebuild and redeploy the code.

share|improve this answer
    
Thank you for the suggestion Deepu. :) –  Ahmed Jabar Nov 5 '11 at 9:58

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.