Muhammedh
Muhammedh

Reputation: 504

How to add a custom web part to a webpart page through code?

I wanna how to add a custom web part to a webpart page through code? The custom web part is already deployed to the SharePoint site. It's a MOSS instance.

Upvotes: 2

Views: 1343

Answers (1)

Flo
Flo

Reputation: 27455

To place a web part on a page you have to use the SPLimitedWebPartManager which could be retrieved from the actual SPWeb object.

After creating an instance of the web part you want to add to the page, you call the AddWebPart() method of the web part manager and pass the web part instance as a parameter.

Upvotes: 1

Related Questions