SettingsLink - Classe
Implémente le rendu pour le menu Page de composants WebPart (modifier la Page partagée ou modifier ma Page).
Hiérarchie d’héritage
System.Object
System.Web.UI.Control
Microsoft.SharePoint.WebPartPages.SettingsLink
Espace de noms : Microsoft.SharePoint.WebPartPages
Assembly : Microsoft.SharePoint (dans Microsoft.SharePoint.dll)
Syntaxe
'Déclaration
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class SettingsLink _
Inherits Control _
Implements IDesignTimeHtmlProvider
'Utilisation
Dim instance As SettingsLink
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class SettingsLink : Control,
IDesignTimeHtmlProvider
Remarques
Le menu composant WebPart implémenté par la classe SettingsLink ne s'afficheront que si l'utilisateur dispose des droits nécessaires pour modifier la page. Les options de menu affichées dans le menu dépendent également des autorisations de l'utilisateur.
Si l'accès anonyme est activé, le menu Page de composants WebPart n'est pas rendu jusqu'à ce que l'utilisateur est authentifié. Dans ce cas, le contrôle de AuthenticationButton doit être ajouté à la page.
Le menu rendu par la classe SettingsLink est identique au menu rendu dans la TitleBarWebPart.
Exemples
L'exemple de code suivant montre comment modifier l'affichage du menu Page de composants WebPart.
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);
}
}
}
Cohérence de thread
Tous les membres statique (Partagé dans Visual Basic)s publics de ce type sont thread-safe. Cela n’est pas garanti pour les membres d’instance.