다음을 통해 공유


SPMobileBaseFieldControl.TrySaveFieldValue Method

Saves the PostValue property as the new value for the field.

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

Syntax

'Declaration
Public Overridable Function TrySaveFieldValue As Boolean
'Usage
Dim instance As SPMobileBaseFieldControl
Dim returnValue As Boolean

returnValue = instance.TrySaveFieldValue()
public virtual bool TrySaveFieldValue()

Return Value

Type: System.Boolean
true if the save operation is successful; otherwise, false.

Remarks

In the default implementation, the operation fails if ReadOnly is true.

Notes to Inheritors

We recommend that you maintain the following relationship between the ItemFieldValue, Value, and PostValue properties and the TrySaveFieldValue method in your derived classes.

  • ItemFieldValue is the value of the field after the most recent saved change. Unsaved changes, whether made by the user in the UI or by code behind, are not reflected in ItemFieldValue.

  • Value is usually identical to ItemFieldValue immediately after each load of a page or postback, but it can be changed. Typically the change is made through the UI and is not saved until the user takes additional action, such as clicking a Save control. Before the save, Value and ItemFieldValue have different values.

  • PostValue is identical to Value in most cases, but it can be useful when users are entering values for Value that are not in the format that the field expects. Use PostValue to hold the correctly formatted version of the value. For example, if the field holds a percentage that users are entering as whole numbers, but the field requires that the value be a fraction of 1, PostValue could be Value divided by 100.

  • TrySaveFieldValue is called when a change to a field is being saved, usually as part of an iteration trough all the fields of a list item. It writes the value of PostValue to both ItemFieldValue and Value.

For example, suppose the field is Boolean and rendered as a check box. When the page first loads, ItemFieldValue is false and the check box is not checked**[.]** This means that Value is also false, and so is PostValue because there is no special formatting for this Boolean field. The user clicks the check box and Value (and PostValue) become true. The user clicks a Save button and ItemFieldValue becomes true.

For a second example, suppose the field is a text field in which users enter a percentage as a whole number, but for which values are stored as a fraction of 1. When the page first loads, the ItemFieldValue, is 0.15 and Value is 15. PostValue is 0.15. The user changes the 15 to 40 and Value becomes 40, and PostValue becomes 0.4. The user clicks a Save button and ItemFieldValue becomes 0.4.

See Also

Reference

SPMobileBaseFieldControl Class

SPMobileBaseFieldControl Members

Microsoft.SharePoint.MobileControls Namespace