a Method to set the title of webpart in cot

xiaoxiao2021-03-05  25

how to set the title of a webpart without modifying the webpart's property in IE the first time when it is imported and allow user to change the title in IE later by modify the webpart's property. i try many ways, but the below is one of those , please let me know if anyone find a better way

1. Define a Public Property

String WebPartTitle = "WebPlaza Admin"; const string web_part_title = "WebPlaza admin";

///

/// custom web part title /// [Browsable (true), Category ( "Miscellaneous"), DefaultValue (WEB_PART_TITLE), WebPartStorage (Storage.Personal), FriendlyName ( "Custom WebPart "), Description (" Use this property to set the weight ")] public string webparttitle {get {return webparttitle;}

Set {WebPartTitle = value;}}

2. Override OnPrereder Method

Protected Override Void OnPrender (Eventargs E) {this.title = this.WebPartTitle; Base.onPrender (e); // this.saveproperties = true;

}

3. Override GetToolParts Method

public override ToolPart [] GetToolParts () {ToolPart [] toolparts = new ToolPart [2]; WebPartToolPart wptp = new WebPartToolPart (); CustomPropertyToolPart custom = new CustomPropertyToolPart (); toolparts [0] = wptp;

Hide the default title "; toolparts [1] = Custom; Return Toolparts; Return Toolparts;

转载请注明原文地址:https://www.9cbs.com/read-38751.html

New Post(0)