【问题标题】:sharepoint 2010. SPField set control for edit and previewsharepoint 2010. SPField 设置用于编辑和预览的控件
【发布时间】:2011-08-31 16:08:24
【问题描述】:

我需要为我创建的共享点字段添加自定义编辑器。 如何设置编辑模式和预览模式的控制。将是两个不同的控件!

我发现我可以覆盖 FieldRenderingControl。 但是如何判断当前模式是编辑还是预览呢?

谢谢。

【问题讨论】:

    标签: sharepoint-2010 sharepoint-2007 custom-fields custom-field-type


    【解决方案1】:

    在您的自定义字段渲染控件 (BaseFieldControl) 中检查成员“ControlMode”,它的类型为 SPControlMode

    protected override void CreateChildControls()
    {
      base.CreateChildControls();
    
      if (ControlMode == SPControlMode.Display)
      {
        // create controls for display view form
      }
      else
      {
        // create controls for edit/new form
      } 
    

    还可以查看继承自SPFieldmethods“GetFieldValueAsText()”和“GetFieldValueAsHtml()”。由于用于在非表单位置显示字段内容。例如在列表视图或版本历史记录中。

    【讨论】:

    • 谢谢。这正是我想要的。
    猜你喜欢
    • 1970-01-01
    • 2010-09-08
    • 1970-01-01
    • 2017-04-12
    • 1970-01-01
    • 1970-01-01
    • 2018-03-26
    • 2013-06-06
    • 2012-09-15
    相关资源
    最近更新 更多