开发者

sharepoint 2010. SPField set control for edit and preview

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜