Following on from my post of application dev on SharePoint (here), I have had some people ask how to embed ASP.Net User Controls in the pages you can add to your site using Option 4 (see post for more details on what this option is).
Well … i did some digging/research and have this set of steps to achieve this. Here goes:
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\moss.litwareinc.com80\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/*” mce_src=”~/_controls/*” IncludeSubFolders=”True” Safe=”True” AllowRemoteDesigner=”True” />
5. In your ASPX page add the following:
<%@ Register src=”~/_controls/SomeControl.ascx” mce_src=”~/_controls/SomeControl.ascx” TagName=”somecontrol” TagPrefix=”uc2″ %>
<uc2:somecontrol id=”mycontrol1″ runat=”server”></uc2:somecontrol>
6. Run your ASPX page and your control should render correctly.