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.
Step1:
Create a user control (*.ascx) file.
Step2:
Put the ascx in C:\Inetpub\wwwroot\wss\VirtualDirectories\1111\USerControls\
Where USerControls is a custom created folder in virtual directory.
Step3:
Copy the usercontrol dll in GAC
Step4:
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=1.0.0.0, Culture=neutral, PublicKeyToken=cb1dc3b73b79f0d0" namespace="usercontrol" typename="*" safe="True">

No comments: