Rendering HTML tag attributes (VB) : Extends WebControl « Custom Controls « ASP.NET Tutorial






Imports System.ComponentModel
Imports System.Web.UI

<DefaultProperty("Text"), _
 ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")> 
Public Class WebCustomControl1
    Inherits System.Web.UI.WebControls.WebControl

    Dim _text As String

    <Bindable(True), Category("Appearance"), DefaultValue("")> _
    Property [Text]() As String
        Get
            Return _text
        End Get

        Set(ByVal Value As String)
            _text = Value
        End Set
    End Property

    Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
        output.RenderBeginTag(HtmlTextWriterTag.Div)

        output.AddAttribute(HtmlTextWriterAttribute.Type, "text")
        output.AddAttribute(HtmlTextWriterAttribute.Id, Me.ClientID)
        output.AddAttribute(HtmlTextWriterAttribute.Name, Me.ClientID)
        output.AddAttribute(HtmlTextWriterAttribute.Value, Me.Text)
        output.RenderBeginTag(HtmlTextWriterTag.Input)
        output.RenderEndTag()

        output.RenderEndTag()
    End Sub


End Class








14.23.Extends WebControl
14.23.1.The Visual Studio Web Control Library class template (C#)
14.23.2.The Visual Studio Web Control Library class template (VB)
14.23.3.Adding a Web Control Library to a Web page
14.23.4.Using the HtmlTextWriter to render an HTML tag (C#)
14.23.5.Using the HtmlTextWriter to render an HTML tag (VB)
14.23.6.Using the HtmlTextWriter to render multiple HTML tags (C#)
14.23.7.Using the HtmlTextWriter to render multiple HTML tags (VB)
14.23.8.Rendering HTML tag attributes (C#)
14.23.9.Rendering HTML tag attributes (VB)