IFieldEditor.OnSaveChange Method (Microsoft.SharePoint.WebControls)
IFieldEditor.OnSaveChange Method (Microsoft.SharePoint.WebControls)
Validates and saves the changes the user has made in the field property editor control.

Namespace: Microsoft.SharePoint.WebControls
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
Syntax

'Usage

Dim instance As IFieldEditor
Dim field As SPField
Dim isNewField As Boolean

instance.OnSaveChange(field, isNewField)

'Declaration

Sub OnSaveChange ( _
    field As SPField, _
    isNewField As Boolean _
)

Parameters

field

The field (column) whose properties are being saved.

isNewField

true to indicate that the field is being created; false to indicate that an existing field is being modified.

Remarks

In general, this method sets the properties of the field parameter in accordance with values of the editor control's child controls. In some cases it may simply copy a value of a child control to a corresponding value of the field parameter. Use this method to validate the values that have been set for the editor control's child controls. This method should throw an SPException object exception if incorrect values have been written to the field parameter.

Example

The following code shows a common structure for implementations of this method. Note:

  • This example does not use the bNewField parameter, which is typical because usually, you want the method to do exactly the same thing whether it is saving values to a new column or saving modified values to an existing column. But if you need different validation logic when creating and saving a new column than when modifying an existing one, you can test the bNewField parameter and branch accordingly.

  • This example begins by converting the field parameter back to its original custom type.

  • The example assumes that you used the recommended naming convention when you derived a custom field class from the SPField class and that you named the derived class by using the pattern field_type_nameField, such as TargetDateField. For more information about custom fields, see Custom Field Classes.

public void OnSaveChange(SPField field, bool bNewField)
{
    field_type_nameField customTypedField = (field_type_nameField)field;

    // TODO: Validate the values of the child controls
    // of the editor control and either throw SPException
    // or write values to customTypedField.
}

See Also

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View