I need to add custom editor for my created sharepoint field. How can i set control both for edi开发者_如何学Pythont mode and preview mode. Will be two different controls!
I found that i can override FieldRenderingControl. But how to determine that current mode is edit or preview?
thanks.
In your custom field render control (BaseFieldControl) check on the member "ControlMode", which is of type SPControlMode.
protected override void CreateChildControls()
{
base.CreateChildControls();
if (ControlMode == SPControlMode.Display)
{
// create controls for display view form
}
else
{
// create controls for edit/new form
}
Also have a look on the methods "GetFieldValueAsText()" and "GetFieldValueAsHtml()" inherited from SPField. Since the are used to display the fields content in non-form location. For instance in list view or in the version history.
精彩评论