Επεξεργασία

Κοινή χρήση μέσω


HyperLinkDataBindingHandler Class

Definition

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
Inheritance
HyperLinkDataBindingHandler

Examples

The following code example creates a class, named CustomHyperLinkDataBindingHandler, which derives from the HyperLinkDataBindingHandler class. 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

Constructors

HyperLinkDataBindingHandler()

Initializes an instance of the HyperLinkDataBindingHandler class.

Methods

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.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to