SPMobileBaseFieldControl.CreateControlForDisplay Method

Creates a control for rendering the field on a Display item form.

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

Syntax

'Declaration
Protected Overridable Function CreateControlForDisplay As MobileControl
'Usage
Dim returnValue As MobileControl

returnValue = Me.CreateControlForDisplay()
protected virtual MobileControl CreateControlForDisplay()

Return Value

Type: System.Web.UI.MobileControls.MobileControl
A MobileControl that renders the field on a Display form.

Remarks

The default implementation calls CreateControlForView.

Examples

The following example shows an override of CreateControlForDisplay that adds a search text box after the item title on a Display form. For the full example, see Walkthrough: Creating a Custom Field Rendering Control for Mobile Pages.

protected override MobileControl CreateControlForDisplay()
{
   string title = Convert.ToString(this.ItemFieldValue);
   if (!String.IsNullOrEmpty(title))
   {
      this.LabelControl.BreakAfter = false;
      this.LabelControl.Text = title + " ";

      this.LinkControl.BreakAfter = false;
      this.LinkControl.Text = "Search";
      this.LinkControl.href = "https://search.msn.com/results.aspx?q=" + title.Replace(' ', '+');

      Panel panel = new Panel();
      panel.BreakAfter = false;
      panel.Controls.Add(this.LabelControl);
      panel.Controls.Add(this.LinkControl);

      return panel;
   }
   return null;
}
Protected Overrides Function CreateControlForDisplay() As MobileControl
   Dim title As String = Convert.ToString(Me.ItemFieldValue)
   If Not String.IsNullOrEmpty(title) Then
      Me.LabelControl.BreakAfter = False
      Me.LabelControl.Text = title & " "

      Me.LinkControl.BreakAfter = False
      Me.LinkControl.Text = "Search"
      Me.LinkControl.href = "https://search.msn.com/results.aspx?q=" & title.Replace(" "c, "+"c)

      Dim panel As New Panel()
      panel.BreakAfter = False
      panel.Controls.Add(Me.LabelControl)
      panel.Controls.Add(Me.LinkControl)

      Return panel
   End If
   Return Nothing
End Function

See Also

Reference

SPMobileBaseFieldControl Class

SPMobileBaseFieldControl Members

Microsoft.SharePoint.MobileControls Namespace