다음을 통해 공유


SPMobileBaseFieldControl.CreateControlForEdit Method

Creates a control for rendering the field on an Edit item form.

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

Syntax

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

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

Return Value

Type: System.Web.UI.MobileControls.MobileControl
A MobileControl that renders the field on an Edit form.

Remarks

The default implementation calls CreateControlForDisplay.

Examples

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

See Also

Reference

SPMobileBaseFieldControl Class

SPMobileBaseFieldControl Members

Microsoft.SharePoint.MobileControls Namespace