Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 915349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:52:22+00:00 2026-05-15T17:52:22+00:00

I’m new to sharepoint. I have a C# solution, that has masterpages and user-controls

  • 0

I’m new to sharepoint. I have a C# solution, that has masterpages and user-controls to be used in a sharepoint site. I have setup my sharepoint dev VM and i can browse the default sharepoint stuff.

How do I add the master pages to Sharepoint? Where do I go from here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T17:52:23+00:00Added an answer on May 15, 2026 at 5:52 pm

    My suggestion would be to deploy the master pages as a feature rather than a manual process. Solutions (WSPs) and Features are the supported way to deploy content/features into sharepoint. A really great tool for sharepoint development is called WSPBuilder

    A master page is deployed into sharepoint as a “module” that you will place into your elements.xml file in the feature.

    Think of a solution as a .cab file with a different extension. Within that is a file called feature.xml which defines the title of your package when its deployed. Features can be activated and deactivated to deploy and undeploy your content into parts of your farm.

    Here is an example of a css file deployed as a Module… Master pages would be similar however, they would deploy into the master page gallery rather than the style library. This module deploys a custom css file into the “Style Library” of a site collection. After this is deployed I used a “Feature Receiver” (event handler) to grab a reference to the SPSite object and modify its alternate stylesheet so that my override took place.

    Feature.xml

    <?xml version="1.0" encoding="utf-8" ?>
    <Feature xmlns="http://schemas.microsoft.com/sharepoint/" 
             Id="63BB13A0-1F9C-4c3b-BE60-10E59CEE0113"
             Title="Custom CSS Feature"
             Description="Deploying a custom CSS using a feature"
             Version="1.0.0.0"
             Hidden="FALSE"
             Scope="Site"
             ReceiverAssembly="CustomCSSFeature, Version=1.0.0.0, Culture=neutral, PublicKeyToken=24f1377a8414d2ed"
             ReceiverClass="CustomCSSFeature.FeatureReceivers.CustomCSSFeatureReceiver"
             >
      <ElementManifests>
        <ElementManifest Location="elements.xml"/>
      </ElementManifests>
    </Feature>
    

    elements.xml – you’d modify this to reflect where master pages are supposed to be deployed I would think that this is the Url property. The Path=”Styles” refers to the relative path within the feature itself where the style sheet resides (e.g. in your visual studio i have a sub folder called styles beneath the folder called CustomCSSFeature and that is where the style sheet exists)

        <?xml version="1.0" encoding="utf-8" ?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <Module Name="OSGStyles" Url="Style Library" Path="Styles" RootWebOnly="TRUE">
        <File Url="custom-css.css" Type="GhostableInLibrary" />
      </Module>
    </Elements>
    

    Then, in my feature receiver class I have activated/deactivated handlers which “apply” the stylesheet to the publishing web. In your case you can likely change the default master page for the website in a feature receiver as well.

    public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPSite site = properties.Feature.Parent as SPSite;
    
            using (SPWeb web = site.OpenWeb())
            {
                PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
                publishingWeb.AlternateCssUrl.SetValue(web.ServerRelativeUrl + 
                    "/Style Library/custom-css.css", true);
                publishingWeb.Update();
                web.Update();
            }
        }
    
        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            SPSite site = properties.Feature.Parent as SPSite;
    
            using (SPWeb web = site.OpenWeb())
            {
                PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
                publishingWeb.AlternateCssUrl.SetValue("", true);
                publishingWeb.Update();
                web.Update();
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.