Apr 1, 2010

Add aspx page to SharePoint WebPart

When developing webparts in sharepoint we are limited in various ways, unleash the complete power of asp .net / visual studio by creating asp .net user controls and wrapping it in a webpart.

Objective: Encapsulate asp .net user control (.ascx) in a webpart, with complete wsp deployment.

WebPart The above visual studio solution will work as a template to quickly create the asp .net user control and wrap it inside a webpart.

Steps Use the template (source code link at the bottom of this blog post) and create asp .net user control webpart for SharePoint.

1) Open Visual Studio

2) Create Asp .Net Web App Project

Click Here to download the Visual Studio 2005 Web Application Project Preview (RC1) link,


3) Delete Default.aspx

4) Create a folder/file structure similar to



5) Copy files as shown below



6) Strong sign the key under properties

7) Change the namespace in all the .cs and ascx files in the project and also modify the properties of the solution as shown below

8) Copy the contents of the following file from the downloaded project template to the project you are creating


Files are:
CreateSolutionPackage.cmd
JQueryWebPartDemo.ddf
Manifest.xml
Elements.xml
Feature.xml
Main.cs
JQueryWebPartDemo.dwp
WebUserControl.ascx
WebUserControl.ascx.cs

Change the namespace, solution id (new guid), public key token (in further steps down), feature id (new guid) in all the above files

Names are kept similar to make sure; the replacement is easy across the files

9) Build the project and go to the bin folder

10) Use "Visual Studio Command Prompt" (Start >> Microsoft Visual Studio 2010 >> Visual Studio Tools >> Visual Studio Command Prompt (2010))

11) OR In case you aren't using the VS Command prompt, you can locate sn.exe at %ProgramFiles%\Microsoft SDKs\Windows\v7.0A\bin\sn.exe

12) sn -T "C:\Documents and Settings\seimossadmin\Desktop\sp.test.wp\sp.test.wp\bin\sp.test.wp.dll"

and update the public key token in all files as required

9) Web Part file, the highlighted portion is public key token of the dll



10) The part in red box should be modified (similar to web.config safecontrol entry)


11) Change all guid’s like solution, feature

12) Under Properties> Build


17) Build the Project


18) Go to the folder where you have setup.exe in the project folder

19) Change the setup.config.exe for correct wsp name and solution id.

20) Run CreateSolutionPackage.cmd

21) Run Setup.exe and install.

22) Make sure wsp timestamp is the latest


You Tube Link:

1) Implementation Doc

2) VS 2005 Doc



Download the user control webart source code or example link,

Happy Coding ...

2 comments:

celerity12 said...

SharePoint 2010 along with Visual Studio 2010 now offers Visual WebPart on same concept or lines.

Something they missed out in earlier releases.

Unknown said...

Hi,Make your links open on a new tab or window is a good practice to do on your Web Design Cochin. When people click on a link on your site and that link points to another website.Thanks..

Pages