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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:31:27+00:00 2026-05-17T01:31:27+00:00

I am currently trying to add a web part to a page. All i

  • 0

I am currently trying to add a web part to a page. All i think is well however i am using a piece of code that i thought returned all existing webparts but really it only returns the web parts that are currently on a given page.

web.GetWebPartCollection(url,storage);

I was hoping to get the reference to my web part that already resides in the web part gallery from the collection returned by the above code but my web part hasn’t been deployed to the page yet as that’s what i am trying to do!!!!

Does anyone know how i can get access to the web part gallery via a piece of c# code?

  • 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-17T01:31:28+00:00Added an answer on May 17, 2026 at 1:31 am

    This should do it:

    SPSite site = new SPSite( siteCollectionUrl );
    SPWeb web = site.OpenWeb();
    SPList webPartGallery = web.GetCatalog( SPListTemplateType.WebPartCatalog );
    ...
    

    siteCollectionUrl is the URL of the site collection for which you wish to load the web part gallery of.

    the SPList webPartGallery will contain all of the web parts in the current site collection’s gallery.

    EDIT:

    It’s probably also worth mentioning the difference in naming conventions in Sharepoint:

    • A sharepoint Site Collection is represented within the object model by a SPSite object.
    • A sharepoint Site is represented by a SPWeb object
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently trying at add ajax to a site, after much reading I discovered that
I'm trying to add a link to a basic MvcScaffolding project that outputs all
I am currently trying to complete a transaction for a web based app, however;
I am currently trying to complete a transaction for a web based app, however;
Hey, I'm currently trying to send an image file to a web server using
I have an ASP.NET site that is not currently using MVC but I'm trying
I am currently working on a project which I think using soap as part
I'm trying to add Atmosphere support to a Wicket-1.5.X web application. (Currently upgrading to
I'm currently trying to add PGP signing support to my small e-mail sending script
I'm currently trying to add an MSChart to a partial view in ASP.NET MVC

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.