Friday, February 5, 2010

Deploying a User Control in MOSS 2007 with Feature

To deploy our user control, Follow below given steps,
 Copy the user controls ascx and cs into directory
~\12\template\controltemplates
Need to create two file Feature.xml and Control.xml


Feature.xml
—————–
#?xml version="1.0″ encoding="utf-8″ ?#
#Feature Id="Generate New GUID"
Title="UserControlTest"
Scope="Farm"
Description="UserControlTest"
Version="1.0.0.0"
xmlns="http://schemas.microsoft.com/sharepoint/"
Hidden="FALSE"#
#ElementManifests#
#ElementManifest Location="control.xml" /#
#/ElementManifests#
#/Feature#

You can define you feature scope in xml attribute 'Scope'.Here we are using farm level for this feature.

control.xml
—————–
#?xml version="1.0″ encoding="utf-8″ ?#
#Elements xmlns=”http://schemas.microsoft.com/sharepoint/"#
#Control Id="UserControlTest"
Controlsrc="~/_controltemplates/ UserControlTest.ascx" Sequence="90″#
#/Control#
#/Elements#

Create a folder to keep these xml files
~\12\TEMPLATE\FEATURES\#Folder Name#

Copy the both files feature and control in the above location
~\12\TEMPLATE\FEATURES\#Folder Name#\Feature.xml
~\12\TEMPLATE\FEATURES\#Folder Name#\control.xml

Now use stsadm to register feature
stsadm -o installfeature -filename CustomQuickLaunch\Feature.xml

Now Open the aspx page on which you want to deploy the control in SharePoint designer add this where you want to deploy the control

#SharePoint:DelegateControl ControlId="UserControlTest" runat="server"##/SharePoint:DelegateControl#

No comments:

Post a Comment