SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created a custom webpart.

I want to get that webpart and add it to my custom application page using code. How can I get it?

share|improve this question
What do you mean by get it? Do you want to use it in the application page code? – user3470 Nov 6 '12 at 9:27
Yes, I want to add that custom webpart in my Application page using code.. – Torque Nov 6 '12 at 10:16
up vote 2 down vote accepted

You can get all the Web Parts on a specific site by accessing the Web Part Gallery List.
For example:

SPWeb web = SPContext.Current.Web;
SPList list = web.Lists["Web Part Gallery"];
foreach(SPListItem item in list.Items)
  // do something
share|improve this answer
Thanx Moussa, It worked for me. So it means all the webparts are stored in a List/Library.. I was struggling for last 5-7 hours to get webpart from site. – Torque Nov 6 '12 at 10:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.