Webpart property default value can be set using DefaultValue property, as shown below. Note that to set the default value, the value should be stored in a constant variable, otherwise it doesn't work properly.
//Namespaces required using System.ComponentModel; using System.Web.UI.WebControls.WebParts; const string const_listName = "ListName"; private string _listName = const_listName; [Personalizable(PersonalizationScope.Shared)] [WebBrowsable(true)] [Category("My Category")] [WebDisplayName("List Name")] [WebDescription("Provide list name to get all the items.")] [DefaultValue(const_listName)] public string ListName { get { return _listName; } set { _listName= value; } }
No comments:
Post a Comment