如何修改自定义Webpart的标题?
在事件里很好写
比如private void BtnText_Click(object sender, EventArgs e)
{
this.Title = this.txtTitle.Text;
}
另外网上比较浒的一个方法是:
public override ToolPart[] GetToolParts()
{
ToolPart[] toolparts = new ToolPart[2];
WebPartToolPart wptp = new WebPartToolPart();
CustomPropertyToolPart custom = new CustomPropertyToolPart();
toolparts[0] = wptp;
//hide the default title property
//wptp.Hide(Microsoft.SharePoint.WebPartPages.WebPartToolPart.Properties.Title);
toolparts[1] = custom;
return toolparts;
}
可是大多数时候由于页面中不上一个Webpart,,有时也会互相打架,导致无效!
其实下面的方法才是正解
protected override void OnInit(EventArgs e)
{
base.OnInit (e);
this.Title = "Set title here...";
}
新问题是:如何将一个HyperLink做WebPart的标题?