SPMobileBaseFieldControl.CreateControlForEdit 方法

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

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

语法

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

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

返回值

类型:System.Web.UI.Control
呈现编辑表单上的字段MobileControl

备注

默认实现调用CreateControlForDisplay

示例

The following example shows an override of CreateControlForEdit that adds an "OVERDUE" to the item title on an Edit item form. For the full example, see Walkthrough: Creating a Custom Field Rendering Control for Mobile Pages.

protected override MobileControl CreateControlForEdit()
{
   MobileControl myEditControl = null;
   if (this.Item != null && this.Field != null)
   {
      if (this.NeedEllipsisRendering)
      {
         myEditControl = this.CreateControlForDisplay();
      }
      else
      {
         if (!this.Page.IsPostBack)
         {
            string strEdit = this.Field.GetFieldValueForEdit(this.ItemFieldValue);
            string overDue = "OVERDUE: ";

            SPListItem item = this.ListItem;
            if (item["Expires"] != null)
            {
               System.DateTime date = (DateTime)item["Expires"];
               if (date.CompareTo(System.DateTime.Today) < 0)
               {
                  this.TextBoxControl.Text = overDue + strEdit;
               }
               else
               {
                  this.TextBoxControl.Text = strEdit;
               }
            }
         }
         myEditControl = this.TextBoxControl;
      }
   }
   return myEditControl;
}
Protected Overrides Function CreateControlForEdit() As MobileControl
   Dim myEditControl As MobileControl = Nothing
   If Me.Item IsNot Nothing AndAlso Me.Field IsNot Nothing Then
      If Me.NeedEllipsisRendering Then
         myEditControl = Me.CreateControlForDisplay()
      Else
         If Not Me.Page.IsPostBack Then
            Dim strEdit As String = Me.Field.GetFieldValueForEdit(Me.ItemFieldValue)
            Dim overDue As String = "OVERDUE: "

            Dim item As SPListItem = Me.ListItem
            If item("Expires") IsNot Nothing Then
               Dim [date] As Date = CDate(item("Expires"))
               If [date].CompareTo(Date.Today) < 0 Then
                  Me.TextBoxControl.Text = overDue & strEdit
               Else
                  Me.TextBoxControl.Text = strEdit
               End If
            End If
         End If
         myEditControl = Me.TextBoxControl
      End If
   End If
   Return myEditControl
End Function

另请参阅

引用

SPMobileBaseFieldControl 类

SPMobileBaseFieldControl 成员

Microsoft.SharePoint.Mobile.WebControls 命名空间