Compartir a través de


SettingsLink Class

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

Inheritance Hierarchy

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

Namespace:  Microsoft.SharePoint.WebPartPages
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public NotInheritable Class SettingsLink _
    Inherits Control _
    Implements IDesignTimeHtmlProvider

Dim instance As SettingsLink
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public sealed class SettingsLink : Control, 
    IDesignTimeHtmlProvider

Remarks

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.

Examples

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

Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.ComponentModel
Imports Microsoft.SharePoint.WebPartPages
Imports Microsoft.SharePoint
Imports System.Xml.Serialization


Namespace SettingsLinkExample
   <XmlRoot([Namespace] := "SettingsLinkExample"), 
      ToolboxData("<{0}:WPRenderSettingsLink 
      runat=server></{0}:WPRenderSettingsLink>")>  _
   Public Class WPRenderSettingsLink
      
      Inherits Microsoft.SharePoint.WebPartPages.WebPart
      Private mylink1 As Microsoft.SharePoint.WebPartPages.SettingsLink
      Private mylink2 As Microsoft.SharePoint.WebPartPages.SettingsLink
      Private mylink3 As Microsoft.SharePoint.WebPartPages.SettingsLink
      Private mylink4 As Microsoft.SharePoint.WebPartPages.SettingsLink
      
      Public Sub New()
      End Sub
      
      Protected Overrides Sub CreateChildControls()
         Dim [text] As LiteralControl
         [text] = New LiteralControl("<br>No Text specified:<br>")
         Me.Controls.Add([text])
         mylink1 = New Microsoft.SharePoint.WebPartPages.SettingsLink()
         Me.Controls.Add(mylink1)
         [text] = New LiteralControl("<br>")
         Me.Controls.Add([text])
         [text] = New LiteralControl("<hr><br>Text specified and 
            font:<br><FONT face=Verdana size=6>")
         Me.Controls.Add([text])
         mylink2 = New Microsoft.SharePoint.WebPartPages.SettingsLink("LinkText")
         Me.Controls.Add(mylink2)
         [text] = New LiteralControl("</font><br>")
         Me.Controls.Add([text])
         
         [text] = New LiteralControl("<hr><br>Text specified no font:<br>")
         Me.Controls.Add([text])
         mylink3 = New Microsoft.SharePoint.WebPartPages.SettingsLink("LinkText")
         Me.Controls.Add(mylink3)
         [text] = New LiteralControl("<br>")
         Me.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"">")
         Me.Controls.Add([text])
         mylink4 = New Microsoft.SharePoint.WebPartPages.SettingsLink("LinkText")
         Me.Controls.Add(mylink4)
         [text] = New LiteralControl("</td></tr></table>")
         Me.Controls.Add([text])
      End Sub
      
      
      ' Render the WebPart
      Protected Overrides Sub RenderWebPart(output As HtmlTextWriter)
         Me.EnsureChildControls()
         Me.RenderChildren(output)
      End Sub
   End Class
End Namespace
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);
        }
    }
}

Thread Safety

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

See Also

Reference

SettingsLink Members

Microsoft.SharePoint.WebPartPages Namespace