使用Visual Studio创建简单的自定义Web Part 部件属性
2014-06-21 17:05
471 查看
使用Visual Studio创建简单的自定义Web Part 部件属性
自定义属性使用额外的选项和设置拓展你的Web part部件。本文主要讲解如何使用Visual Studio创建简单的自定义Web Part 部件属性。1. 打开Visual Studio,点击文件--新建项目--空白SharePoint项目CustomWPProperties。部署为场解决方案。
2. 右击项目添加新项Web Part部件WPPropertyExample,点击添加。
3. 右击WPPropertyExample.cs,点击查看代码。
4. 添加代码,最后是这样的:
using System; using System.ComponentModel; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using Microsoft.SharePoint; using Microsoft.SharePoint.WebControls; using System.Xml.Serialization; namespace CustomWPProperties.WPPropertyExample { public class WPPropertyExample : WebPart { Label lblTitle = new Label(); public enum SharePointLists { Stats, Products, Customers, } protected SharePointLists listOfList; [Personalizable(PersonalizationScope.User), WebBrowsable, WebDisplayName("Available Lists"), WebDescription("Available Lists in SharePoint Site.")] public SharePointLists MySticks { get { return listOfList; } set { listOfList = value; } } protected override void CreateChildControls() { lblTitle.Text = "Web Part with Property"; this.Controls.Add(lblTitle); } } }
5. 点击生成--部署解决方案。
6. 在SharePoint站点,点击网站操作--编辑页面--添加Web部件,在Custom类中选中WPPropertyExample,点击添加。
7. 编辑这个Web部件,在属性窗格可以看到:
相关文章推荐
- 使用Visual Studio创建简单的自定义Web Part 部件属性
- 使用Visual Studio创建简单的自己定义Web Part 部件属性
- 使用Visual Studio 创建可视Web Part部件
- 使用Visual Studio在标准Web Part 部件中创建事件处理器
- 使用Visual Studio在标准Web Part 部件中创建事件处理器
- 使用Visual Studio 创建可视Web Part部件
- 使用Visual Studio 创建可视Web Part部件
- IOS_简单创建tableView并使用自定义的单元格
- 使用Orca在Visual Studio安装项目中创建自定义对话框
- 使用Visual Studio 创建新的Web Part项目
- 使用程序创建自定义Web部件Web Part
- 创建一个简单的web服务器(二):使用自定义的类加载器来替换URLClassLoader
- 使用ATL创建简单ActiveX控件(二) —— 添加方法/属性和枚举
- (41)自定义标签库开发(简单标签的使用和带属性的标签)
- 简单属性,方法,对象的创建和使用
- 使用Visual Studio 2010 创建简单的Silverlight应用程序
- 使用Visual Studio 创建新的Web Part项目
- WSSv3 Technical Articles_使用Visual Studio 2005扩展创建Windows SharePoint Services 3.0 Web Part
- 使用程序创建自定义Web部件Web Part
- SharePoint 创建一个简单的Web Part 部件