Deploying ASP.NET UserControls(.ascx) 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:

<SafeControl src=”~/_controls/*” IncludeSubFolders=”True” Safe=”True” AllowRemoteDesigner=”True” />

Also make sure the trustlevel entry is set to the below

<trustLevel name=”WSS_Medium” policyFile=”C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\config\wss_mediumtrust.config” />
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.

Write me if you have any diffculties.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s