SPMobileBaseFieldControl.CreateControlForDisplay 方法

创建用于显示项目表单上的字段呈现控件。

命名空间:  Microsoft.SharePoint.Mobile.WebControls
程序集:  Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)

语法

声明
Protected Overridable Function CreateControlForDisplay As Control
用法
Dim returnValue As Control

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

返回值

类型:System.Web.UI.Control
呈现该字段显示窗体上的MobileControl

备注

默认实现调用CreateControlForView

示例

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.NavigateUrl = "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.NavigateUrl = "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

另请参阅

引用

SPMobileBaseFieldControl 类

SPMobileBaseFieldControl 成员

Microsoft.SharePoint.Mobile.WebControls 命名空间