Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. eval ?!?

eval ?!?

Scheduled Pinned Locked Moved ASP.NET
javascriptquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    beastyboy
    wrote on last edited by
    #1

    Hello, Suppose I have 3 textboxes named: txtBox1, txtBox2 and txtBox3 Now for some reason I want to fill the boxes depending on their number: I mean something like this: txtBox(i).Text = "something" I know this is ridiculous but I hope you guys see what I mean. (something like the javascript eval function) Can I do something like that in VB-code?? Thanks for the comments respect 2B respected

    G 1 Reply Last reply
    0
    • B beastyboy

      Hello, Suppose I have 3 textboxes named: txtBox1, txtBox2 and txtBox3 Now for some reason I want to fill the boxes depending on their number: I mean something like this: txtBox(i).Text = "something" I know this is ridiculous but I hope you guys see what I mean. (something like the javascript eval function) Can I do something like that in VB-code?? Thanks for the comments respect 2B respected

      G Offline
      G Offline
      gnjunge
      wrote on last edited by
      #2

      Well, you can loop through the Controls collection of your page. Then check the type of the control (to see if it is indeed a textbox) and then get the id (which will be a string) and do your string manipulation on that. in code it would be something like:

            For Each oControl As Control In Me.Controls
                  If oControl.GetType().Name = "TextBox" Then
                      If oControl.ID = "txtBox1" Then
                          CType(oControl, TextBox).Text = "something"
                      End If
                  End If
              Next
      

      This should give you an idea of how to do it. Gideon

      G 1 Reply Last reply
      0
      • G gnjunge

        Well, you can loop through the Controls collection of your page. Then check the type of the control (to see if it is indeed a textbox) and then get the id (which will be a string) and do your string manipulation on that. in code it would be something like:

              For Each oControl As Control In Me.Controls
                    If oControl.GetType().Name = "TextBox" Then
                        If oControl.ID = "txtBox1" Then
                            CType(oControl, TextBox).Text = "something"
                        End If
                    End If
                Next
        

        This should give you an idea of how to do it. Gideon

        G Offline
        G Offline
        gnjunge
        wrote on last edited by
        #3

        Or you can use make a loop from 1 to x and then in the loop you place ctype(me.FindControl("txtBox" & i),TextBox).Text = "something"

        B 1 Reply Last reply
        0
        • G gnjunge

          Or you can use make a loop from 1 to x and then in the loop you place ctype(me.FindControl("txtBox" & i),TextBox).Text = "something"

          B Offline
          B Offline
          beastyboy
          wrote on last edited by
          #4

          This is EXACTLY what I was looking for!!! ;) I was searching after that eval-thing but this would be working fine Thx a lot gideon respect 2B respected

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups