InformationBar Class
Represents the message bar at the top of a form.
System.Object
System.Web.UI.Control
Microsoft.SharePoint.WebControls.SPControl
Microsoft.SharePoint.WebControls.TemplateBasedControl
Microsoft.SharePoint.WebControls.FormComponent
Microsoft.SharePoint.WebControls.InformationBar
System.Web.UI.Control
Microsoft.SharePoint.WebControls.SPControl
Microsoft.SharePoint.WebControls.TemplateBasedControl
Microsoft.SharePoint.WebControls.FormComponent
Microsoft.SharePoint.WebControls.InformationBar
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
InformationBar
Description
The Microsoft.SharePoint.WebControls.InformationBar sealed class inherits from the Microsoft.SharePoint.WebControls.FormComponent class which provides the derivation for Windows SharePoint Services form-rendering controls.
The InformationBar control provides information regarding a SPListItem object, namely:
FileUploadedMessage – will check SPUtility.IsCheckedOut property if the ItemContext.FormContext.UploadMode mode is in the correct state. If so, a resource managed message is rendered to standard output.
ApprovalMessage – will check if the SPList.EnableModeration property is set to true determining if the form requires approval. If so, a resource managed message is rendered to standard output.
EmailCalendarMessage – will check if the SPList is of SPListTemplateType.Events and whether the SPList.Fields collection contains SPBuiltInFieldId.EmailSender value. If so, a resource managed message is rendered to standard output.
CopySourceInfo – if the ListItem.CopySource is valid, the source information regarding the SPListItem object is rendered to standard output.
AssignToEmailMessage – if the SPList.EnableAssignToEmail a resource managed message is rendered to standard output.
In order to handle the presentation layer of the bar, the Microsoft.SharePoint.WebControls.GenericInformationBar class is used. Inheriting from Microsoft.SharePoint.WebControls.RepeatedControls, GenericInformationBar provides relevant HTML Table creation through literal HTML strings being rendered to standard output, along with other stylistic elements.
Usage Scenario
The primary usage of InformationBar is limited to the shipped software on various SharePoint forms since it provides a wealth of information from a SPlist and SPListItem context. Heaviest representation of the control is found on list related form pages.
When developing custom classes that inherit from FormComponent, usage of the control is also customary. In the below, MyClass is inheriting from FormComponent and the CreateChildControls method is being overridden. The FormMode of the current context is being tested in a switch statement, and if the SPControlMode is set to Display, a new InformationBar object is being created. The InformationBar.ItemContext property is being set to the class instance ItemContext, and the object is then added to the current instance control collection.
C# Code Example
public class MyClass : FormComponent
{
protected override void CreateChildControls()
{
switch (SPContext.Current.FormContext.FormMode)
{
case SPControlMode.Display:
{
InformationBar bar = new InformationBar();
bar.ID = "My Bar";
bar.ItemContext = ItemContext;
Controls.Add(bar);
}
break;
}
}
}
VB.NET Code Example
Public Class [MyClass]
Inherits FormComponent
Protected Overloads Overrides Sub CreateChildControls()
Select Case SPContext.Current.FormContext.FormMode
Case SPControlMode.Display
If True Then
Dim bar As New InformationBar()
bar.ID = "My Bar"
bar.ItemContext = ItemContext
Controls.Add(bar)
End If
Exit Select
End Select
End Sub
End Class
Adam Buenz
SharePoint Foundation MVP - http://www.sharepointsecurity.com
The Microsoft.SharePoint.WebControls.InformationBar sealed class inherits from the Microsoft.SharePoint.WebControls.FormComponent class which provides the derivation for Windows SharePoint Services form-rendering controls.
The InformationBar control provides information regarding a SPListItem object, namely:
FileUploadedMessage – will check SPUtility.IsCheckedOut property if the ItemContext.FormContext.UploadMode mode is in the correct state. If so, a resource managed message is rendered to standard output.
ApprovalMessage – will check if the SPList.EnableModeration property is set to true determining if the form requires approval. If so, a resource managed message is rendered to standard output.
EmailCalendarMessage – will check if the SPList is of SPListTemplateType.Events and whether the SPList.Fields collection contains SPBuiltInFieldId.EmailSender value. If so, a resource managed message is rendered to standard output.
CopySourceInfo – if the ListItem.CopySource is valid, the source information regarding the SPListItem object is rendered to standard output.
AssignToEmailMessage – if the SPList.EnableAssignToEmail a resource managed message is rendered to standard output.
In order to handle the presentation layer of the bar, the Microsoft.SharePoint.WebControls.GenericInformationBar class is used. Inheriting from Microsoft.SharePoint.WebControls.RepeatedControls, GenericInformationBar provides relevant HTML Table creation through literal HTML strings being rendered to standard output, along with other stylistic elements.
Usage Scenario
The primary usage of InformationBar is limited to the shipped software on various SharePoint forms since it provides a wealth of information from a SPlist and SPListItem context. Heaviest representation of the control is found on list related form pages.
When developing custom classes that inherit from FormComponent, usage of the control is also customary. In the below, MyClass is inheriting from FormComponent and the CreateChildControls method is being overridden. The FormMode of the current context is being tested in a switch statement, and if the SPControlMode is set to Display, a new InformationBar object is being created. The InformationBar.ItemContext property is being set to the class instance ItemContext, and the object is then added to the current instance control collection.
C# Code Example
public class MyClass : FormComponent
{
protected override void CreateChildControls()
{
switch (SPContext.Current.FormContext.FormMode)
{
case SPControlMode.Display:
{
InformationBar bar = new InformationBar();
bar.ID = "My Bar";
bar.ItemContext = ItemContext;
Controls.Add(bar);
}
break;
}
}
}
VB.NET Code Example
Public Class [MyClass]
Inherits FormComponent
Protected Overloads Overrides Sub CreateChildControls()
Select Case SPContext.Current.FormContext.FormMode
Case SPControlMode.Display
If True Then
Dim bar As New InformationBar()
bar.ID = "My Bar"
bar.ItemContext = ItemContext
Controls.Add(bar)
End If
Exit Select
End Select
End Sub
End Class
Adam Buenz
SharePoint Foundation MVP - http://www.sharepointsecurity.com
- 6/3/2010
- Adam Buenz - MVP