HyperLinkDataBindingHandler 类
定义
提供超链接属性的数据绑定处理程序。Provides a data-binding handler for a hyperlink property.
public ref class HyperLinkDataBindingHandler : System::Web::UI::Design::DataBindingHandler
public class HyperLinkDataBindingHandler : System.Web.UI.Design.DataBindingHandler
type HyperLinkDataBindingHandler = class
inherit DataBindingHandler
Public Class HyperLinkDataBindingHandler
Inherits DataBindingHandler
- 继承
示例
下面的代码示例创建一个名为的类 CustomHyperLinkDataBindingHandler ,该类派生自 HyperLinkDataBindingHandler 类。The following code example creates a class, named CustomHyperLinkDataBindingHandler, which derives from the HyperLinkDataBindingHandler class. 它使用方法解析类的设计时数据绑定 CustomHyperLink DataBindControl 。It resolves design-time data binding for the CustomHyperLink class using the DataBindControl method.
// Derive a class from the HyperLinkDataBindingHandler. It will
// resolve data binding for the CustomHyperlink at design time.
public class CustomHyperLinkDataBindingHandler :
HyperLinkDataBindingHandler
{
// Override the DataBindControl to set property values in
// the DataBindingCollection at design time.
public override void DataBindControl(IDesignerHost designerHost,
Control control)
{
DataBindingCollection bindings =
((IDataBindingsAccessor)control).DataBindings;
DataBinding imageBinding = bindings["ImageUrl"];
// If Text is empty, supply a default value.
if (!(imageBinding == null))
{
CustomHyperLink hype = (CustomHyperLink)control;
hype.ImageUrl = "Image URL.";
}
// Call the base method to bind the control.
base.DataBindControl(designerHost, control);
} // DataBindControl
} // CustomHyperLinkDataBindingHandler
' Derive a class from the HyperLinkDataBindingHandler. It will
' resolve data binding for the CustomHyperlink at design time.
Public Class CustomHyperLinkDataBindingHandler
Inherits HyperLinkDataBindingHandler
' Override the DataBindControl to set property values in
' the DataBindingCollection at design time.
Public Overrides Sub DataBindControl( _
ByVal designerHost As IDesignerHost, ByVal control As Control)
Dim bindings As DataBindingCollection = _
CType(control, IDataBindingsAccessor).DataBindings
Dim imageBinding As DataBinding = bindings("ImageUrl")
If Not (imageBinding Is Nothing) Then
Dim hLink As CustomHyperLink = CType(control, CustomHyperLink)
hLink.ImageUrl = "Image URL."
End If
MyBase.DataBindControl(designerHost, control)
End Sub
End Class
构造函数
| HyperLinkDataBindingHandler() |
初始化 HyperLinkDataBindingHandler 类的实例。Initializes an instance of the HyperLinkDataBindingHandler class. |
方法
| DataBindControl(IDesignerHost, Control) |
为指定控件解析设计时数据绑定。Resolves design-time data-binding for the specified control. |
| Equals(Object) |
确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object. (继承自 Object) |
| GetHashCode() |
作为默认哈希函数。Serves as the default hash function. (继承自 Object) |
| GetType() |
获取当前实例的 Type。Gets the Type of the current instance. (继承自 Object) |
| MemberwiseClone() |
创建当前 Object 的浅表副本。Creates a shallow copy of the current Object. (继承自 Object) |
| ToString() |
返回表示当前对象的字符串。Returns a string that represents the current object. (继承自 Object) |