Add a Edit This Webpart link from within a web part in SharePoint

Add a Edit This Webpart link from within a web part in SharePoint by adding the following javascript to your web part output:


javascript:MSOTlPn_ShowToolPane2Wrapper('Edit',this,'"+ this.ID +"');

Here's a sample of how you would do this in the CreateChildControls method:


protected override void CreateChildControls()

{

Controls.Clear();
base.CreateChildControls();

StringBuilder sbOut = new StringBuilder();

Literal ltlOutput = new Literal();

if (SiteURL == null || SiteURL == "")

{

sbOut.Append(
"Please <a href=\"javascript:MSOTlPn_ShowToolPane2Wrapper('Edit',this,'"+ this.ID +"');\">modify this web part</a> and set the web site where the list data is or will be stored.");



}



ltlOutput.Text += sbOut.ToString();

Controls.Add(ltlOutput);


}

Source:
http://blogs.msdn.com/b/cliffgreen/archive/2008/03/17/create-open-tool-pane-link-in-asp-net-2-0-web-parts-for-sharepoint.aspx

Comments

Popular posts from this blog

Getting Authentication Prompt When Accessing SharePoint Web Services

How To use ASPNET_SetReg to store encrypted data in the registry and then decrypt the data for use in your app

PowerShell Script to Clean the Windows Installer Directory