Tags: | Categories: Blog Posted by admin on 3/9/2009 5:55 PM | Comments (0)

This is a response for all the emails I have received about using Composite Control in VB:

 

The previous post was in C# 

http://alpascual.com/blog/al/archive/2006/06/19/The-power-of-CompositeControl.-Another-skeleton-class-.aspx

 

Second part using VB.NET:

Imports System

Imports System.Collections.Generic

Imports System.ComponentModel

Imports System.Text

Imports System.Web

Imports System.Web.UI

Imports System.Web.UI.WebControls

 

 

<DefaultProperty("Text"), ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")> _

Public Class WebCustomControl1

    Inherits CompositeControl

 

    Protected Literal1 As Literal

 

 

    <Bindable(True), Category("Appearance"), DefaultValue(""), Localizable(True)> Property Text() As String

        Get

            Dim s As String = CStr(ViewState("Text"))

            If s Is Nothing Then

                Return String.Empty

            Else

                Return s

            End If

        End Get

 

 

 

        Set(ByVal Value As String)

            ViewState("Text") = Value

        End Set

    End Property

 

 

    Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)

        MyBase.OnLoad(e)

 

      

    End Sub

   

 

    Protected Overrides Sub CreateChildControls()

        MyBase.CreateChildControls()

 

        Literal1 = New Literal()

        Literal1.Text = "<BR>"

 

 

    End Sub

 

    Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)

        MyBase.Render(writer)

 

        Literal1.RenderControl(writer)

 

    End Sub

 

End Class

 

blog comments powered by Disqus