Export (0) Print
Expand All

SettingsLink Class

Implements rendering for the Web Part Page menu (Modify Shared Page or Modify My Page).

System.Object
  System.Web.UI.Control
    Microsoft.SharePoint.WebPartPages.SettingsLink

Namespace:  Microsoft.SharePoint.WebPartPages
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No

[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class SettingsLink : Control, 
	IDesignTimeHtmlProvider

The Web Part menu implemented by the SettingsLink class will only be displayed if the user has sufficient rights to modify the page. The menu options displayed on the menu also depend on the user's permissions.

If anonymous access is turned on, the Web Part Page menu will not be rendered until the user is authenticated. In this case, the AuthenticationButton control should be added to the page.

The menu rendered by the SettingsLink class is identical to the menu rendered in the TitleBarWebPart.

The following code example shows how to change the display of the Web Part Page menu.

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using Microsoft.SharePoint.WebPartPages;
using Microsoft.SharePoint;
using System.Xml.Serialization;

namespace SettingsLinkExample
{
    [XmlRoot(Namespace="SettingsLinkExample")]
    [ToolboxData("<{0}:WPRenderSettingsLink 
        runat=server></{0}:WPRenderSettingsLink>")]

    public class WPRenderSettingsLink : 
        Microsoft.SharePoint.WebPartPages.WebPart
    {
        private Microsoft.SharePoint.WebPartPages.SettingsLink mylink1;
        private Microsoft.SharePoint.WebPartPages.SettingsLink mylink2;
        private Microsoft.SharePoint.WebPartPages.SettingsLink mylink3;
        private Microsoft.SharePoint.WebPartPages.SettingsLink mylink4;

        public WPRenderSettingsLink()
             {
             }

        protected override void CreateChildControls()
        {
            LiteralControl text;
            text = new LiteralControl("<br>No Text specified:<br>");
            this.Controls.Add(text);
            mylink1 = new Microsoft.SharePoint.WebPartPages.SettingsLink();
            this.Controls.Add(mylink1);
            text = new LiteralControl("<br>");
            this.Controls.Add(text);
            text = new LiteralControl("<hr><br>Text specified and 
                font:<br><FONT face=Verdana size=6>");
            this.Controls.Add(text);
            mylink2 = new Microsoft.SharePoint.WebPartPages.SettingsLink("LinkText");
            this.Controls.Add(mylink2);
            text = new LiteralControl("</font><br>");
            this.Controls.Add(text);

            text = new LiteralControl("<hr><br>Text specified no font:<br>");
            this.Controls.Add(text);
            mylink3 = new Microsoft.SharePoint.WebPartPages.SettingsLink("LinkText");
            this.Controls.Add(mylink3);
            text = new LiteralControl("<br>");
            this.Controls.Add(text);

            text = new LiteralControl("<hr><br>Text specified splink 
                added:<br><table><tr><td align=\"right\" 
                valign=\"bottom\" class=\"ms-SPLink\" 
                style=\"padding:5px\">");
            this.Controls.Add(text);
            mylink4 = new Microsoft.SharePoint.WebPartPages.SettingsLink("LinkText");
            this.Controls.Add(mylink4);
            text = new LiteralControl("</td></tr></table>");
            this.Controls.Add(text);
        }

        // Render the WebPart
        protected override void RenderWebPart(HtmlTextWriter output)
        {
            this.EnsureChildControls();
            this.RenderChildren(output);
        }
    }
}

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2015 Microsoft