me.name

if I do

Protected textBox1 As new TextBox()

hiw can I get ;

Me.textBox1.ID = "textBox1" 

I mean "textBox1" the name i gave as a string 

thank you



Answer this question

me.name

  • mentally_disturbed

    Dynamically adding controls at runtime does not require a unique identifier.  The following is perfectly valid:

    Dim a As Textbox
    Dim i As Integer = 0

    For i = 0 To 100
         a = New Textbox()
         a.Text = i.ToString()
         Me.Controls.Add(a)
    Next


    I don't think that it is possible to do what you are asking.

    Is this Web Development

  • staceywilliam

    I know how to add Dynamicly controls, I want to add dynamicly id in the way I am looking for , it works to get a class name as a string 

    Dim ns, nsn As String
    ns = Me.GetType().BaseType.Namespace

    it works also for any object

    I shall find it

    thanks anyway

  • Yevgeniy K

    I'm sorry, but I don't understand what you are asking.

    Textbox has a Name property.  When you drag a Textbox onto a form, a name gets assigned to it ("Textbox1," "Textbox2," etc).  However, creating a textbox via code will not automatically assign a name to it.  Are you asking how to assign a name to it   You can set the name property. 

  • tosun

    I want to create codeBehind a textBox

    I name it as Follow :

    textBox1 as TextBox

    I want to get "textBox1" as a string

    if you add dynamicly many controls you need for client side an ID


    Why shoul I do

    textBox1 as TextBox
    textBox1.ID = "TextBox1"

    when I have allready it, I just want to get it as string

    something like

    Private Function GetNameType(ByVal o As Object) As String
    Return o.GetType.Name.ToString
    End Function

    but getting the name itself not the type name


    thank you




  • me.name