Custom Look-And-Feel Using Masterpages

Topics: Developer Forum, User Forum
Mar 6, 2007 at 1:00 AM
Hey all,

I am looking for some guidance/insight into how the SLK pages (Lobby.aspx in particular) derive their masterpage and what options are available for using my own masterpages.

Looks like the SLK pages use "~/_layouts/application.master" for their masterpage.

I can get them to use my masterpage if I put it in the layouts folder (where application.master lives). But my masterpage lives in the _catalogs directory of the site collection, and I don't want to maintain two copies.

Furthermore, it seems to me that those pages should use whatever masterpage is set as the default for the site where the E-Learning action is taking place. This dosen't appear to be the case though.

Anyone using their own masterpage for the SLK pages and if so, what method are you using to reference it and manage it?

(I had previously posted this inquiry here: http://www.codeplex.com/SLK/Thread/View.aspx?ThreadId=2222)

Nick MSFT
Mar 6, 2007 at 6:52 PM

Hi Nick,

SLK pages are SharePoint application pages and are therefore by nature common to all the site collections. Customizations made to the Master Page do not change these application pages and that is the reason the e-learning actions page does not have the masterpage of the enclosing site collection. Customization per site collection therefore has to be done at runtime in the codebehind files.

To customize the SLK application pages (lobby, grading etc.) , the MasterPageFile attribute can be set to the MasterUrl or CustomMasterUrl property of the site collection in context to give the application pages a look and feel of that of the site collection.

A line of code such as the following in the codebehind files should do the trick,
MasterPageFile = SPWeb.MasterUrl;
or
MasterPageFile = SPWeb.CustomMasterUrl;

Hope this helps.

Mar 12, 2007 at 8:44 PM
Hey Vandana,

This is super helpful, thank you.

What are the steps I would follow to add the necessary lines of code to the codebehind files and deploy those onto my site?
Mar 12, 2007 at 8:51 PM
Also, I am wondering why this wasn't included already by default with the SLK pages? Does it just increase the risk that people will "break" things by using bad masterpages?
Mar 14, 2007 at 1:21 AM
The files I am most concerned about having my custom look and feel are Lobby.aspx, AssignmentProperties.aspx and Grading.aspx.

I see where the code behind files are in the SLK Source Code drop but am not sure how to add the code I need to add and redeploy the solution on my server.

Any tips?
Mar 15, 2007 at 2:11 PM
Nick,

The line of code can be added to the page's OnPreInit eventhandler. This can be done by adding the following function to each of the code-behind files,

protected override void OnPreInit(EventArgs e)
{
MasterPageFile = SPWeb.CustomMasterUrl; //can be set to any master file url
base.OnPreInit(e);
}

The developer tools in the source code can be used to build (using the makefile) and deploy (using gac.bat) the solution on the server

The reason, I think, this is not part of the code already is because of the nature of the application. The SLK application is designed to be common to all the site collections. If we feel that this could be a common customization that many here would desire, we can add an 'issue' to that effect and take a decision based on the votes it receives.

Mar 19, 2007 at 8:05 PM
I would like to see it added as an issue I think.

I believe it should inherit whatever masterpage you select for "System Masterpage" on your site. So, it should have the following code added to the code behind files:

 
protected override void OnPreInit(EventArgs e)
{
MasterPageFile = SPWeb.MasterUrl; //set to system masterpage of site
base.OnPreInit(e);
}
 

I would be interested to see if anyone else sees this as something that's relevant. Let's vote!
Jul 11, 2007 at 8:29 PM
Was this added as an Issue as suggested? I would also like the Lobby, Grading, etc. pages to inherit a custom master page instead of application.master. Right now, we're working with a modified application.master page. Not ideal!

Thanks,
Mike
Jul 12, 2007 at 12:43 AM
I am adding this issue now. Vote on it!