Partilhar via


SPMobileBaseFieldControl.CreateControlForNew Method

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

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

Syntax

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

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

Return Value

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

Remarks

The default implementation calls CreateControlForDisplay.

Examples

The following example shows an override of this method that inserts default text in the item title on a New item form. For the full example, see Walkthrough: Creating a Custom Field Rendering Control for Mobile Pages.

protected override MobileControl CreateControlForNew()
{
    MobileControl myNewControl = null;
    if (this.Field != null)
    {
        string text = "Group: Project Name";
        if (!this.Page.IsPostBack)
        {
            this.TextBoxControl.Text = text;
        }
        myNewControl = this.TextBoxControl;
    }
    return myNewControl;
}
Protected Overrides Function CreateControlForNew() As MobileControl
    Dim myNewControl As MobileControl = Nothing
    If Me.Field IsNot Nothing Then
        Dim text As String = "Group: Project Name"
        If Not Me.Page.IsPostBack Then
            Me.TextBoxControl.Text = text
        End If
        myNewControl = Me.TextBoxControl
    End If
    Return myNewControl
End Function

See Also

Reference

SPMobileBaseFieldControl Class

SPMobileBaseFieldControl Members

Microsoft.SharePoint.MobileControls Namespace