Wednesday, May 14, 2008

Using ASP.Net user controls in your WSSV3/MOSS ASPX pages

To use ASP.Net user controls in your WSSV3/MOSS ASPX pages do the following steps:
1. Create a Directory called "_controls" in the root of your sharepoint web site on the file system E.g. C:\Inetpub\wwwroot\wss\VirtualDirectories\SharePointSite\_controls
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 allowremotedesigner="True" safe="True" includesubfolders="True" src="~/_controls/*" />
5. In your ASPX page add the following:
<%@ Register src="~/_controls/SomeControl.ascx" src="~/_controls/SomeControl.ascx" TagName="somecontrol" TagPrefix="uc2" >
And...
<uc2:somecontrol id="mycontrol1" runat="server" />

No comments: