Stellen Sie eine FrageStellen Sie eine Frage
 

BeantwortetCustom Feature and masterpages

  • Samstag, 4. Juli 2009 08:30zdragon TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    HI.
    I've developed a feature (deployed with scope Web ) which has custom pages too.
    I had deployed it to a server which has multiple site collections
    each site collection will have its own look and feel + different masterpages.
    My biggest problem is that I need my feature pages to have the same look and feel as  site were it is deployed.
    is there any SPTag that I can use to load masterpages specified for the site? or I have to do it programmaticaly?
    --

Antworten

  • Sonntag, 5. Juli 2009 15:33Dave Hunter TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     Beantwortet

    Hi,

    To make application pages (pages which exist in the _layouts directory) to use a different masterpage or to customise the application.master, you have two options

    1. Modify the _layouts in a supported manner, please see http://support.microsoft.com/kb/944105.  It involves either backing up the _layouts and modifying the masterpage or creating a copy of the _layouts and changing the virtual directory to use the new folder (my preferred solution).
    2. Create a httpmodule which replaces the application.master with your custom one, please see http://graegert.com/?p=781

    I prefer the HttpModule, but I am a developer, if you don't have Visual Studio then use option 1.

    Hope this helps

    Dave 


    My SharePoint Blog - http://www.davehunter.co.uk/blog
    • Als Antwort markiertzdragon Sonntag, 5. Juli 2009 21:55
    •  

Alle Antworten

  • Samstag, 4. Juli 2009 16:16Sébastien Sougnez TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     Enthält Code
    Hello,

    Maybe I didn't understand your probleme, but normally, in your ASPX page, you have something like this :

    <%@ Page Language="C#" Inherits="PageApp1.PageApp1" MasterPageFile="~/_layouts/application.master" EnableViewState="false" EnableViewStateMac="false" %> 
    

    So you juste have to change the MasterpageFile attribute, haven't you ?



    http://www.areaprog.com
  • Sonntag, 5. Juli 2009 09:10zdragon TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     Enthält Code
    MasterPageFile="~/_layouts/application.master" 

    replacig this bit will work only for 1 individual site collection.

    the feature have to be enabled in other site collections too and those othere sites wil have their own masterpage..

    ex. Site Coll 1. will have SiteOne.master

    Collection 2: SiteTwo.master.

    The problem now is that my feature aspx pages have to pick up one of those master pages. depending in what site collection is loaded.

     


    --
  • Sonntag, 5. Juli 2009 09:39Sébastien Sougnez TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     Enthält Code
    Hello,

    have you a way to retrieve the name of the masterpage to attach to the page ? If yes, you can change the master page of the page in PreInit event :

    void Page_PreInit(Object sender, EventArgs e)
    {
    this.MasterPageFile = "~/NewMaster.master";
    }

    I said that, but I don't know if your issue is to retrieve the name of the master page or to change the page dynamically :-)
    http://www.areaprog.com
  • Sonntag, 5. Juli 2009 09:47zdragon TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    Hi!
    I do consider this sollution too.
    there is an elegant way to do it with SPWeb.MAsterUrl property
     http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.masterurl.aspx

      is  there another way to do it? for example with an HTML tag ?
    ex, <SPMasterPage .... />

    --
  • Sonntag, 5. Juli 2009 09:51Sébastien Sougnez TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    Hello,

    I don't think that you can. I searched on web and I found this link : http://www.odetocode.com/articles/450.aspx. Nothing in this article speaks about changing page dynamicaly by the ASPX code...
    http://www.areaprog.com
  • Sonntag, 5. Juli 2009 10:26zdragon TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    Hello,

    I don't think that you can. I searched on web and I found this link : http://www.odetocode.com/articles/450.aspx. Nothing in this article speaks about changing page dynamicaly by the ASPX code...
    http://www.areaprog.com


    in the link above it says : The 'MasterPageFile' property can only be set in or before the 'Page_PreInit' event.

    so it is possible to do it .


    --
  • Sonntag, 5. Juli 2009 15:33Dave Hunter TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     Beantwortet

    Hi,

    To make application pages (pages which exist in the _layouts directory) to use a different masterpage or to customise the application.master, you have two options

    1. Modify the _layouts in a supported manner, please see http://support.microsoft.com/kb/944105.  It involves either backing up the _layouts and modifying the masterpage or creating a copy of the _layouts and changing the virtual directory to use the new folder (my preferred solution).
    2. Create a httpmodule which replaces the application.master with your custom one, please see http://graegert.com/?p=781

    I prefer the HttpModule, but I am a developer, if you don't have Visual Studio then use option 1.

    Hope this helps

    Dave 


    My SharePoint Blog - http://www.davehunter.co.uk/blog
    • Als Antwort markiertzdragon Sonntag, 5. Juli 2009 21:55
    •  
  • Montag, 6. Juli 2009 11:21kesav7902 TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    hello,

    u can create a page using the publishing page object in the object model (creating the page dynamically in a publishing site)there by u can assigne the master page to it on the fly as a part of the feature reciever code --> acheiveing the same look and feel across the site collection where ever u wish to have ....

    cheers,
    keshav.