Results 1 to 4 of 4

Thread: How to access html objects via class property?

  1. #1
    jay_agno is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Apr 2012
    Posts
    9
    Reputation
    0

    How to access html objects via class property?

    For example I have these codes in HTML:
    HTML Code:
    <asp:TextBox ID="textBox1" runat="server" class="MyClass1"></asp:TextBox>
    <asp:TextBox ID="textBox2" runat="server" class="MyClass1"></asp:TextBox>
    My question is, in code behind, how can I access those text boxes via vb.net?
    Is there any code that is somehow related to the code below?:
    Code:
    For Each ID in MyClass1
      ' Here in iteration, ID will be textBox1, or textBox2, etc..
    Next
    Thank you for your help.

  2. #2
    Lotok is offline VB.NET Forum Genius
    .NET Framework
    .NET 4.0
    Join Date
    Jan 2012
    Location
    Scotland
    Posts
    193
    Reputation
    22
    I would be tempted to use a list of textboxes

    Code:
    Dim textboxes As New List(Of TextBox)
    textboxes.Add(textbox1)
    textboxes.Add(textbox2)
    
    For i = 0 To textboxes.Count - 1
    'do something to or with textboxes(i)
    Next

  3. #3
    jay_agno is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Apr 2012
    Posts
    9
    Reputation
    0
    Moderator may now close this thread.
    Thank you.

  4. #4
    Lotok is offline VB.NET Forum Genius
    .NET Framework
    .NET 4.0
    Join Date
    Jan 2012
    Location
    Scotland
    Posts
    193
    Reputation
    22
    LOL, you're welcome.
    Last edited by Lotok; 05-04-2012 at 2:57 AM.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking