sharepoint 如何利用 Features 和 DelegateControl 来 部署自定义的 UserControl
1. 新建一个UserControl ,名字叫 MyControl.ascx
2. 一般默认的许多UserControl都是放在目录: C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES; 我在该目录下面新建了一个文件夹: test, 然后把那个UserControl放在该目录下面.
3.在C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\TEMPLATE\FEATURES下面 建一个 存放 自定义 Feature 的文件夹: Featuretest
在里面建2个XML文件 分别是 Feature.xml 和 testFeature .xml
4. Feature.xml :
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<Feature Id="FDA209CD-3A7B-426d-AE05-6AA4811C7C96"
Title="测试"
Description="测试"
Version="1.0.0.0"
Scope="Farm"
Hidden="false"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="testFeature .xml"/>
</ElementManifests>
</Feature>
Title="测试"
Description="测试"
Version="1.0.0.0"
Scope="Farm"
Hidden="false"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="testFeature .xml"/>
</ElementManifests>
</Feature>
5:testFeature .xml:
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Control Id="testid" Sequence="100" ControlSrc="~/_controltemplates/test/MyControl.ascx"/>
</Elements>
<Control Id="testid" Sequence="100" ControlSrc="~/_controltemplates/test/MyControl.ascx"/>
</Elements>
6.激活 Feature:
stsadm –o installfeature –filename <Feature.xml 文件相对于 12\TEMPLATE\FEATURES 文件夹的路径 >
7.使用 现在你的Feature 已经部署完成 在页面里 可以写
<SharePoint:DelegateControl ID="testid" runat="server" ControlId="Footer"></SharePoint:DelegateControl>
来显示你的 UserControl