Monday, March 16, 2009

Adding Custom user Control in SharePoint Page

User Control can be added to SharePoint master file or it can be embedded in a web part. The steps for attaching a user control in SharePoint are described below.
Create a user control (*.ascx) file.
Put the ascx in C:\Inetpub\wwwroot\wss\VirtualDirectories\1111\USerControls\
Where USerControls is a custom created folder in virtual directory.
Copy the usercontrol dll in GAC
Edit the web config file as below

Add the usercontrols folder as safe controls
SafeControl src="~/userControls/*" includesubfolders="True" safe="True" allowremotedesigner="True">

Add the user controls dll as safe controls

SafeControl assembly="usercontrol, Version=, Culture=neutral, PublicKeyToken=cb1dc3b73b79f0d0" namespace="usercontrol" typename="*" safe="True">

No comments: