Imports Microsoft.VisualBasic
Imports System.Web.UI.WebControls

Namespace MikesControls
    Public Class MyControl2
        Inherits WebControl

        Private _cmd As String
        Private _typeName As String

        Public Property MySqlCommand() As String
            Get
                Return _cmd
            End Get
            Set(ByVal value As String)
                _cmd = value
            End Set
        End Property

        Public Property TypeName() As String
            Get
                Return _typeName
            End Get
            Set(ByVal value As String)
                _typeName = value
            End Set
        End Property

        Public Sub New()
            ' Do Nothing
            ' Warning: The constructor gets called before the Property values
            ' are read and set.
            '
        End Sub

        Protected Overrides Sub RenderContents(ByVal writer As System.Web.UI.HtmlTextWriter)
            Dim dataSource As Object
            Dim srcType As Type
            Dim srcMethodInfo As System.Reflection.MethodInfo
            Dim result As Object

            srcType = Type.GetType(_typeName)
            dataSource = Activator.CreateInstance(srcType)

            'dataSource = Me.Parent.FindControl(_dataSourceID)
            'srcType = dataSource.GetType()
            srcMethodInfo = srcType.GetMethod(_cmd)
            result = srcMethodInfo.Invoke(dataSource, Nothing)

            writer.Write(CType(result, Integer))
        End Sub


    End Class
End Namespace

