How to add custom property in custom webpart using VS 2012
来源:互联网 发布:黑猩猩智商知乎 编辑:程序博客网 时间:2024/06/03 01:39
How to add custom property in custom webpart using VS 2012
Sometimes we want to add some custom properties to custom web part, then we can edit the value of the custom properties. here is the picture
And the StorePortal is my custom properties, and I also set the default value of the custom properties.
Firstly, yopu should create a empty sharepoint project and add new item call webpart to the project.
Second, if you want to add cutom properties, just use the follow code:
[WebBrowsable(true), WebDisplayName("This is Name"), // The display name WebDescription("This is Description, e.g. 'blog1#blog2'"), // the description of the custom properties Personalizable(PersonalizationScope.Shared), Category("This is new category")] // to display the properties in a new section public string BlogWeb { get; set; }
the code is following:
[ToolboxItemAttribute(false)] public class render : WebPart { #region Custom web part properties // blog web related url, e.g. "/blog" [WebBrowsable(true), WebDisplayName("Blog web related url"), WebDescription("Blog web related url, e.g. 'blog1#blog2'"), Personalizable(PersonalizationScope.Shared), Category("StorePortal")] public string BlogWeb { get; set; } // the number of show tags, e.g. 10 [WebBrowsable(true), WebDisplayName("The number of tags"), WebDescription("The number of tags, e.g. 1"), Personalizable(PersonalizationScope.Shared), Category("StorePortal"), DefaultValue(NumberLimitDefaultValue)] public uint NumberLimit { get { return this.numberLimit; } set { this.numberLimit = value; } } #endregion #region private fields private const uint NumberLimitDefaultValue = 10; private uint numberLimit = NumberLimitDefaultValue; #endregion protected override void CreateChildControls() { //try //{ // you can cutom to coding, and if you want to call the custom properties. For example: this.BlogWeb //} //catch { } }}
- How to add custom property in custom webpart using VS 2012
- How to add custom scripts
- How to add custom fields to Customer Registration and Account page in magento
- How to add a Custom Pull to Refresh in your iOS Application
- How to do custom statistic in OPNET
- How to create custom price in Magento?
- How to Programmatically Add/Delete Custom Options in Magento? - See more at: http://apptha.com/blog/
- How to make a custom keyboard in iOS 8 using Swift
- How to add custom title bar to android application
- How to add a custom build step to MSBuild Projects
- How to add custom validator to paper-input?
- HOW TO Custom DSDT
- Add Custom Background Image to UINavigationBar in iOS 5
- Neat Stuff to Do in List Controls Using Custom Draw
- Neat Stuff to Do in List Controls Using Custom Draw
- Neat Stuff to Do in List Controls Using Custom Draw
- How To Install Custom Component in Delphi (into existing package).
- How to define a custom separator in TLex
- 左侧数据移到右侧 select 实现法
- 2014 --人人网笔试算法汇总
- 2013.9.10兰亭集势 (技术笔试题) 部分题总结
- VS2012 开发SharePoint 2013 声明式workflow action(activity)之 HelloWorld
- 票据承兑
- How to add custom property in custom webpart using VS 2012
- Hashtable和HashMap的差异化分析
- php发送get、post请求的几种方法
- Win32 SDK函数MessageBox的模拟实现(C语言版)
- 百家姓128进制数的乘法运算
- 求动归求树的高度 ,判断是不是搜索树后根遍历
- 给一名准90后程序员的指导——学好IT?无用论?
- 使用Protégé修改RDF文件并生成OWL文件
- android中获取项目的版本信息