Feature setting Masterpage & CSS doesn't work when included in SiteTemplate - but does work when activated manually

Hi,
I'm experiencing a strange behaviour recently. I wrote a feature with an EventReceiver that sets the masterpage and alternate css file for the current spweb it is activated for. When I activate that feature manually it works like expected. But if I include
the same feature in a SiteTemplate and it is called during site-creation, it doesn't work. I debugged it and stepped through it. As far as I can tell everything looks right. It sets the masterpage and css file like it should and throws no error. But when the
site loads in the end, it suddenly still uses the v4.master and no alternateCSS. How can that be?
If I deactivate the feature then manually and activate it again, it works...
Here's the feature:
const string masterPage = MyOfficeProcess.master";
const string searchMasterPage = "MyMinimal.master";
const string alternateCss = "MyOfficeAlternateProcess.css";
public override void FeatureActivated(SPFeatureReceiverProperties properties)
SPWeb web = (SPWeb)properties.Feature.Parent;
using (SPWeb topLevelSite = web.Site.RootWeb)
string relativePath = topLevelSite.ServerRelativeUrl;
if (!relativePath.EndsWith("/"))
relativePath += "/";
if (web.WebTemplate == "SRCHCENTERLITE" || web.WebTemplate == "SRCHCEN" || web.WebTemplate == "SRCHCENTERFAST")
web.CustomMasterUrl = relativePath + "_catalogs/masterpage/" + searchMasterPage;
else
web.MasterUrl = relativePath + "_catalogs/masterpage/" + masterPage;
web.CustomMasterUrl = relativePath + "_catalogs/masterpage/" + masterPage;
web.AlternateCssUrl = relativePath + "Style Library/My/" + alternateCss;
web.UIVersion = 4;
web.Update();

Hi,
You can put a copy of your master page within the template site, use that for the site's master page, and then save the site as a template then check whether it works.
Here is a similar thread for your reference:
http://sharepoint.stackexchange.com/questions/30699/featureactivated-not-called-for-site-template
Thanks,
Dennis Guo
TechNet Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Dennis Guo
TechNet Community Support

Similar Messages

  • HT5022 After setting up, no longer appears in either version of Airport but DOES WORK! Why?

    After setting up, no longer appears in either version of Airport but DOES WORK! Why?

    Hey Bob...
    So far, using wireless only on the AirPort Extreme... (No Ethernet Devices or USB connected)
    Yes to "create a wireless network".
    My Cable Modem is the latest Motorola Docis 3, The APE is M8799LL/A Model A1034
    Yes both versions...
    More detail.... If I reset the APE, it shows up just fine in 5.6.
    I  go through configuration. I choose APE name, new wireless network, enter Wireless Network name and password.
    Set for WPA.
    Anyway, Airport 5.6 claims success and restarts APE. Never finds it again, (unless I reset it again. Went thorugh this process 3 times with same results... )
    Anyway. the utility cannot "see" APE but my devices, (iPads, iPods, iPhone, Macbooks, Android devices as well), All can see APE and connect to it.
    So, NOT major issue except that in order to make ANY changes to the APE, I must do a reset..
    It's just WEIRD!    

  • Iphone/ipad/ipod charger wire wont work for iphone or ipod but does work for ipad very strange

    guys this is so odd and pointless but for some reason my charger wont let my iphone charge or ipod but it works for iphone. iphone running ios 7 same with ipad. any solutions?

    Hello there, Kareem77.
    The following Knowledge Base article provides some great steps for troubleshooting your issue:
    iPhone and iPod touch: Charging the battery
    http://support.apple.com/kb/HT1476
    If the issue persists, the first article also refers to this:
    iOS: Not responding or does not turn on
    http://support.apple.com/kb/TS3281
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • Part of .pdf doesn't show text when opened in firefox but does show when downloaded to the desktop

    when I open this link within firefox the chart (page 3 on) doesn't open. When I download the .pdf to my desktop all the information is filled in.
    http://www.tradestocksamerica.com/dsr-pdf/TheDailyStockReport_2013-02-25-Monday_Morning.pdf
    i noticed on my laptop, where the entire contents of the .pdf is viewable, within Firefox - under
    Firefox / Tools / Options / Applications / there is an app called JPS file whereas on the desktop this app does not appear

    Have you researched the site you mentioned? I went to it and WOT gave me a red flag.
    At this moment, we are aware of issues pertaining to PDF.js and we suggest installing the following add-on: https://addons.mozilla.org/en-US/firefox/addon/pdfjs/

  • Adobe Flash Builder pureMVC_As3 2.0.4 login works in Flash Builder when developing and testing but does not when deployed.

    I have Adobe Flash Builder 4.7 with air 15. I am using as3 PureMVC swc. The application works and logins to my server during development and testing. But the issue comes when I deploy the application in IOS 8. The login does not work. Can anyone help. Thanks in advance.

    Just as an add on note.  What we can't determine is when the SWF file is run either in a a flash player 9 or with IE
    it does not work. (i.e. no email and variable that is sent back is undefined)  In flash player 10, it warns about some
    security settings.
    but in FLASH CS4 authoring environment, using the test movie, ctrl+enter, it runs like a champ, sends the email, gets
    the variable back.
    The server its being run on is a LAN based IIS server for Intranet use.  So the local PC is connecting to it fine in "Test movie" mode.
    but if you run that swf any other way, its does not work for love nor money!  How do you debug for that!  The asp code was even cut down
    to a simple HELLO WOLD example and that still did not work.  Of course it did work in Test Movie mode!

  • RT target works OK in volatile mode but does not when deployed in non-volatile mode.

    I have developed several applications using the NI cRIO-9073 Integrated chassis. The applications work perfectly well in volatile mode (development), but when I come to deploy the the RT target as an executable the application does not work. Now, I ran the LabVIEW Real-Time 1 Solution application and the same problem occured, in this case, the USER1 LED came on then went off as if an error occured. I finally trapped an error around the shutdown stage, attached, funny thing is though the error code doe not make sense as I am not using the FPGA, running in scan mode, however, I could be missing something.
    (Note: I have obviously modified the Real-Time 1 course solution to use my existing hardware)
    Now this is where it gets puzzling, 3 years ago I did the old RT course, LabVIEW Real-Time Application Development, I have now run the solution for this course, on the same target as the RT1 solution and it works!!!
    I have contacted NI support with no solution to this problem. In the meatime I have a NI cRIO-9704 on order and when it arrives I will try again.
    I really need to know, however what is going on here, does anyone out there have any Ideas? have you experienced any similar problems?
    Thanks
    Neil

    Note to self - Include attachment...
    Error Log
    Status: TRUE
    Code: -65589
    Source: Shared Variable in Chamber Control.vi->RT Main.vi
    This error or warning occurred while reading the following Shared Variable:
    \\NI-cRIO9073-0180F3D1\Thermocouple Mod\Temperature-cRIO
    \\localhost\Thermocouple Mod\Temperature-cRIO
    Error -65589 occurred at an unidentified location
    Possible reason(s):
    CompactRIO:  The FPGA VI you are running does not contain the DMA FIFOs that the RIO Scan Interface requires. Ensure that the modules under the Chassis item in the project match the modules in the chassis, and recompile the FPGA VI.

  • Why does Jaws works with the project when previewed in browser but does not when it is published?

    I am using Jaws 15.0.110024 and Captivate 8 in windows.

    Perhaps you need to add the published location to the list of trusted locations for the Flash Player?
    Click here for info on how to do that
    Cheers... Rick

  • My HP Envy 15-j051 does not charge when computer is on but does charge when powered off

    whenever I am on and plugged in if get plugges in but not charging yet when I shut down and keep power supply plugged in it charges the battery. I have checkd the battery and it said primary-OK (1) dis systems check all passed
    This question was solved.
    View Solution.

    @lagrit1023 ,
    Hello and thank you for posting on the HP support forums.  What you may have happening here is a problem with the power regulation on the motherboard or an issue with not enough amps  from the power supply.
    Can you try the power supply on another notebook or have someplace you can take it to be checked?
    The only other way to check this if you have already done the battery checks and so on is to get the system sent in for repair.  For this you will have to contact HP phone support.
    Please call our technical support at 800-474-6836. If you live outside the US/Canada Region, please click the link below to get the support number for your region.
    http://www8.hp.com/us/en/contact-hp/ww-phone-assist.html
    Please let me know how things go.
    Thank you again for posting and have a great day.
    Please click the "Thumbs Up" on the bottom right of this post to say thank you if you appreciate the support I provide!
    Also be sure to mark my post as “Accept as Solution" if you feel my post solved your issue, it will help others who face the same challenge find the same solution.
    D5GR
    I work on behalf of HP

  • Printing NOT working from PS CS3 - Z3100 but DOES work with Lightroom 2

    I have been printing on a Mac with PS CS3 using a Z3100. All has been fine. Today I'm trying to print a 46x54" image from PS. I have not been able to make this work. PS sits for a while, thinks for a while, chews up resources, hangs on occassion as reported by the Activity Monitor, and then .... nothing. PS sits there and the print goes away. The job never appeared in the print monitor. I did all the usual. Rebooted the world, reinstalled the HP Z3100 drivers, and the same thing. I then gave it a shot, after many hours, and thought I'd try Lightroom 2.0. Holy mother of Michael Phelps, the print job was submitted in no time and the job is humming along with no issues. The only issue is that Lightroom is not showing Absolute Colorimetric as an option which I use and chose Perceptual instead.
    The file size was 1.2 GB and 16-bit. I lowered to 8 bit for PS and still to no avail. I printed in 8-bit on LR 2.0.
    Is this an issue with Photoshop? I'm running a Mac Pro Quad with on OS X 10.4.11 and 6 GB of RAM.

    Something has gone wrong with how Lightroom finds and communicates with Photoshop.
    That could be a registry string, or some preference within Lightroom.
    The Lightroom forum is more likely to be able to help you solve this.

  • Newest version Flash Player doesn't work online, but does work when using Dreamweaver files locally?

    Newest version Flash Player v 11.2.202.235 doesn't work when trying to view Flash video online, but does work when using the same Dreamweaver files locally?
    Win7/64, Firefox 12, 16 gb ram, core i3 @3.07GHz

    Define "doesn't work" - what do you see instead of the expected Flash content?
    Does that happen for any Flash object on the Internet, or only your Dreamweaver files?

  • My MacBook Pro doesn't accept CDs or DVDs anymore, but it did when I bought it 2 years ago. How can I get it to read disks again?

    My MacBook Pro doesn't accept CDs or DVDs anymore, but it did when I bought it 2 years ago. How can I get it to read disks again?
    My quess is that the new software just doesn't allow the disk drive to work. I would love an explanation why this doesn't work and some help getting it to work. It's really frustrating because I get a bunch of CDs from work and never get to listen to them on my MacBook.

    Make sure the discs are free of finger prints. The optical drive cannot read a disc with smudges and dust.
    Check Finder > Preferences > General
    Make sure:  CDs, DVDs, and iPods, is selected.

  • I updated to yosemite and now if someone is using imessage and sends a text message to my phone it doesn't show up on my phone but does on my computer.  I don't want messages on my computer!  How do I get this to go away and work like it used to?

    I updated to yosemite and now if someone is using imessage and sends a text message to my phone it doesn't show up on my phone but does on my computer.  I don't want messages on my computer!  How do I get this to go away and work like it used to?

    Follow the instructions under the heading "How to unlink a phone number" on this page.

  • When I go to yahoo with my iPhone 6  the pages will not enlarge when I pinch them but it works on my iPad. Does anyone know what's wrong?

    When I go to yahoo with my iPhone 6  the pages will not enlarge when I pinch them but it works on my iPad. Does anyone know what's wrong? Also the same on boyfriends phone he's eith Virgin and I'm with Vodafone do it cant be the providers.

    Thanks for the link but none of those described the problem. No error message pops up. It just says "Accessing Itunes Store" but it never actually does. This only occurs when my iPhone is plugged in though.

  • I can't seem to use the 'Check seats' link on Delta when I use Firefox but Safari works fine. I get the message 'not available at this time' when using Firefox but when I go to Safari it works fine.

    I can't seem to use the 'Check seats' link on the Delta Airlines site when I use Firefox but Safari works fine. I get the message 'not available at this time' when using Firefox but when I go to Safari it works fine. I love Firefox but this sucks!

    That issue can be caused by corrupted cookies.
    Clear the cache and the cookies from sites that cause problems.
    "Clear the Cache":
    *Firefox > Preferences > Advanced > Network > Offline Storage (Cache): "Clear Now"
    "Remove Cookies" from sites causing problems:
    *Firefox > Preferences > Privacy > Cookies: "Show Cookies"
    *http://kb.mozillazine.org/Cookies

  • No sound when playing videos/youtube but speakers work

    No sound when playing videos/youtube but speakers work. Mute is not on that I can see. Volume is maxed. Devices are enabled. Speakers tested. Have tried with and without headphones. 
    I tried to do a Driver Update but Toshiba Support doesnt recognize my model/serial numbers so I dont know what Driver to use. 
    I have a Satellite C50-05U
    Model number PSC12C-05U00S
    Serial number XXXXXXXXX
    I tried a restore from previous backup but it hasnt helped. any suggestions? 
    [Moderator edit to remove serial number.]
    Solved!
    Go to Solution.

    I tired this and it worked:
    Adobe Flash Player plug-in
    https://support.google.com/chrome/answer/108086
    Adobe Flash Player is directly integrated with Google Chrome and enabled by default. Available updates for Adobe Flash Player are automatically included in Chrome system updates.
    If you want to use Adobe Flash Player in other browsers, you’ll need to separately download the Adobe Flash Playerfor those browsers.Enable or disable Adobe Flash Player
    These instructions apply to Google Chrome on Windows, Mac, Linux, and Chrome OS.
    Type chromelugins in the address bar to open the Plug-ins page.
    On the Plug-ins page that appears, find the "Flash" listing.
    To enable Adobe Flash Player, click the Enable link under its name.
    To disable Adobe Flash Player completely, click the Disable link under its name.
    Note: If you've previously installed Adobe Flash Player separately, you'll see two files listed for the plug-in. If both are listed as enabled, the version bundled with Chrome will be used. To enable a specific version of Adobe Flash Player, clickDetails in the upper-right corner of the page. Then click the Enable link for the version of Adobe Flash Player you want to enable. The table below shows the filename for the version that is integrated with Google Chrome. more at the link above ..... 

Maybe you are looking for