BaseFieldControl.Value 属性
当在某个派生类中重写,获取或设置在 UI 中的字段的值。
命名空间: Microsoft.SharePoint.WebControls
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
Public Overridable Property Value As Object
Get
Set
用法
Dim instance As BaseFieldControl
Dim value As Object
value = instance.Value
instance.Value = value
public virtual Object Value { get; set; }
属性值
类型:System.Object
当在某个派生类, Object值,该值代表在 UI 中字段的值重写。通常,这是子控件,例如标签或文本框中,实际呈现字段的文本。
备注
默认实现get访问器只返回空引用(无 在 Visual Basic 中)。set访问器没有默认实现。
如果set访问器覆盖具有适合的实际呈现 (例如标签或文本框中) ; 该字段的子控件的类型的逻辑然后,每当BaseFieldControl加载, Value得到ItemFieldValue,相同的值,或如果从未为当前列表项设置字段提供的默认值。(ItemFieldValue是字段的具有作为其FieldRenderingControl属性BaseFieldControlSPField的值。
针对继承者的注释
如果您直接从BaseFieldControl派生类,您必须替代set访问器和Valueget访问器。除了其他原因,这是 ItemFieldValue 的以便OnLoad方法可以授予控制权值在首次请求页的和,以便它可以更新ItemFieldValueValue回发的用户输入值。
任何覆盖set访问器或get取值必须调用EnsureChildControls方法 (这将创建任何子控件,如果它们尚不存在)。这通常是set访问或get访问器第一行。但是,如果都没有指向创建子控件,除非某些属性不空引用(无 在 Visual Basic 中)和不为空字符串,然后您可以先检查所需的值之前调用方法。
如果BaseFieldControl的值为可由用户更改,您的逻辑应直接更改Value ,,然后调用UpdateFieldValueInItem更新ItemFieldValue。这样可以确保相应的值更改事件发生。(UpdateFieldValueInItem假定您已重写Valueget访问器。
示例
The following is an example of an override of the Value property when the derived field control has the same child controls, of the same types, as the parent class (or when any additional child controls declared by the derived class have constant values that are hard coded in a rendering template). Even in this situation, you should call EnsureChildControls unless you have access to the source code of the parent class's Value property and can verify that it calls EnsureChildControls. For the full example, see Walkthrough: Creating a Custom Field Type.
public override object Value
{
get
{
EnsureChildControls();
return base.Value;
}
set
{
EnsureChildControls();
base.Value = (String)value;
}
}
Public Overrides Property Value() As Object
Get
EnsureChildControls()
Return MyBase.Value
End Get
Set(ByVal value As Object)
EnsureChildControls()
MyBase.Value = CType(value, String)
End Set
End Property
另请参阅
引用
Microsoft.SharePoint.WebControls 命名空间