This topic has not yet been rated - Rate this topic

ListFormPageTitle Class

Represents the title control of a list form.

System.Object
  System.Web.UI.Control
    Microsoft.SharePoint.WebControls.SPControl
      Microsoft.SharePoint.WebControls.ListFormPageTitle

Namespace:  Microsoft.SharePoint.WebControls
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class ListFormPageTitle : SPControl
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
ListFormPageTitle
Description

The Microsoft.SharePoint.WebControls.ListFormPageTitle class inherits from the Microsoft.SharePoint.WebControls.SPControl class which serves as the base server control for the other WebControls within the Microsoft.SharePoint.WebControls namespace.

Use of ListFormPageTitle is directly available in shipped SharePoint software on standard list (ListFormWebPart) WebForms (such as NewForm.aspx or EditForm.aspx). Its purpose is to dynamically provide a robust, informative page title for the WebForm. 

The PlaceHolderPageTitle content placeholder on respective WebForms will expect a string value that represents the page title. Since ListFormPageTitle is meant to dynamically build the title, firstly it will interrogate the current list context (SPContext.Current.List) to acquire the SPList.Title property value. Once the title is obtained from the SPList object, there are several appendages that can occur depending on the template type of a list, however they will all use SPUtility.SummarizeText for truncatation, in order to support ellipse suffixes. 

The Usage Scenario

There is heavy representation of ListFormPageTitle internally because of its use on the shipped list WebForms. However, within custom development where list context is available it can provide a mechanism to provide a well-formed, informative string regarding a SPList for consumption into other controls.

In the below, I am instantiating a new ListFormPageTitle object, as well as a new Label object that will render a literal string of text. Following, a static method, CreateTable, will consume the created objects, and setup the organizational layout using a combination of Table, TableRow, and TableCell. The parameter controls are added to their respective TableCell object control collection. Lastly, the created Table is added to the WebPart control collection.

C# Code Example

public class ExampleWebPart : WebPart
{
protected override void CreateChildControls()
{
ListFormPageTitle titleControl = new ListFormPageTitle();
Label titleLabel = new Label();
titleLabel.Text = "My List Title Information Is:";
Table tableToCreate = CreateTable(titleLabel, titleControl);
Controls.Add(tableToCreate);
}

private static Table CreateTable(Control ctrl1, Control ctrl2)
{
Table titleTable = new Table();
TableRow titleRow = new TableRow();
TableCell titleLabel = new TableCell();
TableCell titleControl = new TableCell();

titleLabel.Controls.Add(ctrl1);
titleControl.Controls.Add(ctrl2);

titleRow.Cells.Add(titleLabel);
titleRow.Cells.Add(titleControl);

titleTable.Rows.Add(titleRow);

return titleTable;
} }

Visual Basic .NET Code Example

Public Class ExampleWebPart
Inherits WebPart
Protected Overloads Overrides Sub CreateChildControls()
Dim titleControl As New ListFormPageTitle()
Dim titleLabel As New Label()
titleLabel.Text = "My List Title Information Is:"
Dim tableToCreate As Table = CreateTable(titleLabel, titleControl)
Controls.Add(tableToCreate)
End Sub

Private Shared Function CreateTable(ByVal ctrl1 As Control, ByVal ctrl2 As Control) As Table
Dim titleTable As New Table()
Dim titleRow As New TableRow()
Dim titleLabel As New TableCell()
Dim titleControl As New TableCell()

titleLabel.Controls.Add(ctrl1)
titleControl.Controls.Add(ctrl2)

titleRow.Cells.Add(titleLabel)
titleRow.Cells.Add(titleControl)

titleTable.Rows.Add(titleRow)

Return titleTable
End Function
End Class

Adam Buenz
SharePoint Foundation MVP - http://www.sharepointsecurity.com