Formula una domandaFormula una domanda
 

Con rispostaCustom Feature and masterpages

  • sabato 4 luglio 2009 8.30zdragon Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     
    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?
    --

Risposte

  • domenica 5 luglio 2009 15.33Dave Hunter Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     Con risposta

    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
    • Contrassegnato come rispostazdragon domenica 5 luglio 2009 21.55
    •  

Tutte le risposte

  • sabato 4 luglio 2009 16.16Sébastien Sougnez Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     Contiene codice
    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
  • domenica 5 luglio 2009 9.10zdragon Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     Contiene codice
    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.

     


    --
  • domenica 5 luglio 2009 9.39Sébastien Sougnez Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     Contiene codice
    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
  • domenica 5 luglio 2009 9.47zdragon Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     
    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 .... />

    --
  • domenica 5 luglio 2009 9.51Sébastien Sougnez Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     
    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
  • domenica 5 luglio 2009 10.26zdragon Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     
    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 .


    --
  • domenica 5 luglio 2009 15.33Dave Hunter Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     Con risposta

    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
    • Contrassegnato come rispostazdragon domenica 5 luglio 2009 21.55
    •  
  • lunedì 6 luglio 2009 11.21kesav7902 Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     
    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.