Brian Roisentul
Brian Roisentul

Reputation: 4750

Is it possible to use ASP.NET Web Control into a Webpart project?

I'm developing a webpart in Visual Studio 2010 for SharePoint 2010, and I would like to know if I could add a web control I've already developed for a web application in the past.

When I try to add a new item into the project, I only see the option for adding a Server Control, but it only creates a .cs file instead of a control.

Upvotes: 0

Views: 897

Answers (1)

Steve Danner
Steve Danner

Reputation: 22158

Yes, but you will have to make sure that it's strong-named and can be placed into the server's Global Assembly Cache as that is where all web parts are deployed to. Additionally, if it's not a visual web part, you'll have to create it dynamically in code instead of having a drag and drop surface like a normal ASP.NET application.

Generally speaking, it's not too much different than using a server control in a normal ASP.NET application.

EDIT:

To add a custom server control to your application, you can right click inside the toolbox and select "Choose Items...". You can then browse to your custom assembly containing the server control and click OK. After that, it will appear in your toolbox and you can just drag and drop it onto your visual ascx web part.

Upvotes: 1

Related Questions