0

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?

  • 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
2

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
}
  • 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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