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. Programmatic Location of TextBoxes

Programmatic Location of TextBoxes

Scheduled Pinned Locked Moved Web Development
databasequestionwinformshelp
3 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.
  • M Offline
    M Offline
    Mike L
    wrote on last edited by
    #1

    I must be missing something in the big picture.... Using CodeBehind, how can I dynamically create new controls (in this case, TextBoxes) which I can relocate on the Web Form programatically? I can see how this is possible using Windows Forms (the LEFT and TOP calls are there), but not in a Web Form (I can't seem to find a way to change the location, just WIDTH and HEIGHT). The number (I also can't seem to create controls programatically, either...) and location of text boxes and potentially other controls will vary in my application, depending on the number of db rows retrieved from a user query. Any help is appreciated! Thanks! MikeRoad

    D 1 Reply Last reply
    0
    • M Mike L

      I must be missing something in the big picture.... Using CodeBehind, how can I dynamically create new controls (in this case, TextBoxes) which I can relocate on the Web Form programatically? I can see how this is possible using Windows Forms (the LEFT and TOP calls are there), but not in a Web Form (I can't seem to find a way to change the location, just WIDTH and HEIGHT). The number (I also can't seem to create controls programatically, either...) and location of text boxes and potentially other controls will vary in my application, depending on the number of db rows retrieved from a user query. Any help is appreciated! Thanks! MikeRoad

      D Offline
      D Offline
      DFU23
      wrote on last edited by
      #2

      I'm going to make a quick assumption ... you are using VS.NET, right? First off, I would imagine that you want could dynamically make the new controls whenever you needed to make them, for example, on the click event of a button. However, to position them programmatically you will have to play with their style attributes for this to display correctly in a web browser. First thing is to set the positition to absolute and then you can set the top and left style attributes to set their location on the page. If you are using VS.NET and have the Design Mode of a Web Form open and are using the Grid Layout for the page then you can check the HTML used for the form and see how elements are being positioned on the page that are already set through design mode. Hopefully this will give you some insight. If you are going to be displaying information back to the users from a DB then I would suggest using the DataGrid because of its amazing flexibility. Check out the many articles on http://4guysfromrolla.com[^] for some great resources on ASP.NET.

      Wally Atkins
      Newport News, VA, USA

      M 1 Reply Last reply
      0
      • D DFU23

        I'm going to make a quick assumption ... you are using VS.NET, right? First off, I would imagine that you want could dynamically make the new controls whenever you needed to make them, for example, on the click event of a button. However, to position them programmatically you will have to play with their style attributes for this to display correctly in a web browser. First thing is to set the positition to absolute and then you can set the top and left style attributes to set their location on the page. If you are using VS.NET and have the Design Mode of a Web Form open and are using the Grid Layout for the page then you can check the HTML used for the form and see how elements are being positioned on the page that are already set through design mode. Hopefully this will give you some insight. If you are going to be displaying information back to the users from a DB then I would suggest using the DataGrid because of its amazing flexibility. Check out the many articles on http://4guysfromrolla.com[^] for some great resources on ASP.NET.

        Wally Atkins
        Newport News, VA, USA

        M Offline
        M Offline
        Mike L
        wrote on last edited by
        #3

        Thanks very much for this. I'll give it a try. I'm travelling in China, so my time sync is... well - isn't. But this gives me what I need to get working.

        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