Sunday, October 5, 2008

Deploying asp.net user control in sharepoint

Shown a good way to put custom usercontrols to work with sharepoint pages.

This is the same content that has been posted in http://bestofcyber.wordpress.com/2008/09/16/deploying-aspnet-usercontrolsascx-declared-in-custom-aspx-pages-into-moss-2007-sites/

Consider you are developing a custom application in asp.net out of the box SharePoint for the ease of UI development and deployment ,you might need to also create user controls and use into your aspx pages.

While you are deploying usercontrols(.ascx) file ,you can follow below steps to get the usercontrols rendering in the custom aspx pages I found this way more simple and working 100% fine.

1. Create a Directory called “UserControls” in the root of your SharePoint web site on the file system E.g. C:\Inetpub\wwwroot\wss\VirtualDirectories\80\UserControls

2. Open IIS manager and in the root of your SharePoint site create a VirtualDirectory called “_controls” and point it to that newly created directory.

3. Put your user control in that newly created directory on the filesystem.

4. Open the web.config file and add the following:

Also make sure the trustlevel entry is set to the below


5. In your ASPX page change the existing register directive with the following:

<%@ Register src=”~/_controls/SomeControl.ascx” TagName=”somecontrol” TagPrefix=”uc1″ %>

6. Run your ASPX page and your control should render correctly.

No comments: