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 6789877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:39:29+00:00 2026-05-26T17:39:29+00:00

I have a web part which I’d like to add a custom icon to.

  • 0

I have a web part which I’d like to add a custom icon to. I am using the CatalogIconImageUrl property in the web part schema (let’s say the value is _catalogs/masterpage/MyFolder/MyWebPartResources/MyWebPart_16x16.png).

If I deploy the web part to my development site it finds the path properly.

However, if I am deploying the web part to multi-tier site, it just does not find the URL. For example, if I am deploying the web part to a site collection like http://mysitecollection/SitePages/ or a personal SP site, like http://mysitecollection/my/personal/UserName/

Is there a work around for this?

  • 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-26T17:39:29+00:00Added an answer on May 26, 2026 at 5:39 pm

    chris_walker provided me with this help.

    I’ve added an event receiver to the feature. After that I’ve retrieved the web app root in the Feature Activated method. Finally, I’ve opened the webpart schema as a txt file and replaced one keyword (~sitecollection) with the real site collection URL.

    public class WebPartEventReceiver : SPFeatureReceiver
    {
        public override void FeatureActivated(SPFeatureReceiverProperties properties) {
            SPSite site = properties.Feature.Parent as SPSite;
            if (site != null) {
                SPList webPartsGallery = site.GetCatalog(SPListTemplateType.WebPartCatalog);
                SPListItemCollection allWebParts = webPartsGallery.Items;
                SPListItem webPart = (from SPListItem wp in allWebParts where wp.File.Name == "your.webpart" select wp).SingleOrDefault();
                if (webPart != null) {
                    string siteCollectionUrl = site.ServerRelativeUrl;
                    if (!siteCollectionUrl.EndsWith("/")) { siteCollectionUrl += "/"; }
                    string fileContents = Encoding.UTF8.GetString(webPart.File.OpenBinary());
                    fileContents = fileContents.Replace("~sitecollection/", siteCollectionUrl);
                    webPart.File.SaveBinary(Encoding.UTF8.GetBytes(fileContents));
                }
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple web part with a custom enum property (which SharePoint renders
I have a web part which uses many SharePoint controls like menu, SPGrid, tool
I have defined a personalizable property on a web part and I would like
I have created a SharePoint web part which has custom properties that the user
I have a custom web part which is generating some user data. I have
I have a custom sharepoint web part that is throwing the following exception: System.Security.SecurityException:
We have a web part on which we display some data in a grid.
I have one web part (the provider) which displays insurance claims in a gridview.
I have a SharePoint web part that I wrote in C# which is used
I have a custom web part placed on one of the application page in

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.