Share via


PublishButton Class

Displays a publish button on a form that is used to publish a list item, usually a blog post or comment. When this button is clicked, the draft version of the current list item is approved.

Inheritance Hierarchy

System.Object
  System.Web.UI.Control
    Microsoft.SharePoint.WebControls.SPControl
      Microsoft.SharePoint.WebControls.TemplateBasedControl
        Microsoft.SharePoint.WebControls.FormComponent
          Microsoft.SharePoint.WebControls.SaveButton
            Microsoft.SharePoint.WebControls.PublishButton

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

Syntax

'Declaration
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public Class PublishButton _
    Inherits SaveButton
'Usage
Dim instance As PublishButton
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class PublishButton : SaveButton

Remarks

Publishing is not the same as saving. If, for example, a blog is moderated, saving a post or comment does not make it public. Publishing occurs when a moderator approves the post or comment.

Use the PublishButton class when creating a custom form for reviewing (and possibly also editing) items stored in a SharePoint Foundation list.

You can only use the PublishButton control for items on lists that are enabled for moderation.

Examples

The following code samples show how to instantiate a PublishButton object, give it a text label, and then, in the C# and Visual Basic .NET code samples, add the PublishButton to the controls collection of the page.

[xml]

<SharePoint:PublishButton runat="server" ID="CustomFormPublishButton" Text="I Approve!" />

[C#]

PublishButton CustomFormPublishButton = new PublishButton();
this.Controls.Add(CustomFormPublishButton);

[Visual Basic]

Dim CustomFormPublishButton As PublishButton = New PublishButton()
Me.Controls.Add(CustomFormPublishButton)

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

PublishButton Members

Microsoft.SharePoint.WebControls Namespace

Microsoft.SharePoint.WebControls.SPControlMode