I created a Label control inheriting from Label WebControl in CustomLabel.vb in my project where I want to use it. And I would like to use the code below in source-view as such:
<custom:SettingLabel ID="lblHelloWorld" runat="server"/>
How can I do that without creating a WebContolLibrary and using it as reference?
Namespace InternetLending.Controls
Public Class SettingLabel
Inherits Label
Protected msDefaultText As String
Protected moConfigXML As New ConfigXMLParser()
Public Overridable Property DefaultText() As String
Get
Return Me.msDefaultText
End Get
Set(ByVal vsValue As String)
Me.msDefaultText = vsValue
End Set
End Property
Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
MyBase.OnLoad(e)
If Not String.IsNullOrEmpty(Me.moConfigXML.GetLabelTextByID(Me.ID)) Then
Me.Text = Me.moConfigXML.GetLabelTextByID(Me.ID)
Else
Me.Text = Me.DefaultText
End If
End Sub
End Class
End Namespace
You just need to add this to the top of your page. You don’t need to make a separate library or anything.