JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Adding Methods to User Controls

You can add a method to a user control as you would to any class; just place the implementation of that method into the user control's code. You can make the method public, protected, or private.

For example, here's how we added a method named SetText to the user control in the UserControls example discussed in the In Depth section of this chapter. This method displays text in the label control in the user control and sets the text displayed in the user control:

    Public Sub SetText(ByVal NewText As String)
        Label1.Text = NewText
    End Sub

That's all it takes. See the In Depth section of this chapter for more details on the UserControls example.

Related solution:

Found on page:

Creating Methods


Previous Section Next Section

JavaScript Editor Free JavaScript Editor     JavaScript Editor