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. How can I put controls inside a table cell

How can I put controls inside a table cell

Scheduled Pinned Locked Moved ASP.NET
questioncsharphtmlcsssysadmin
5 Posts 3 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.
  • L Offline
    L Offline
    lnong
    wrote on last edited by
    #1

    I have a TableCell in a Table (both are "runat=server"). My program dynamically generates ASP:Button controls and puts them inside the HtmlTableCell. The Buttons are put at absolute positions using the "position: absolute; top: 10px; left: 20px" style properties (of couse, the top and left values are different for each different button). Inside my table cell, I use GridLayout instead of FlowLayout (default). Here's is a simple skeletion of my code: <table id=table runat=server> <tr id=row runat=server> <td id=cell runat=server ms_position=GridLayout></td> </tr> </table> There is a function in my C# code that creates the buttons, automatically calculates the top and left positions of each button and then add the button to the table cell. My code for adding looks something like this: Button b = new Button(); b.Style.Add("position", "absolute"); b.Style.Add("top", yValue.ToString()); b.Style.Add("left", xValue.ToString()); FindControl("Main").FindControl("table").FindControl("row").FindControl("cell").Controls.Add(b); So far, everything works well. However, if a Button is placed so that some parts of it is outside the bounds of the TableCell, it just sticks outside of the cell. I want that cell to automatically increase or decrease in width to fit the button. Also, if the cell size reachs a certain length (which I can specify), either the Button should be clipped, or there should be scrollbars inside the cell that will allow me to scroll over to see the whole button. I cannot find a way to do this. My explanation may be confusing, but if you follow these steps, you will see what I am taking about: 1) In the Forms Designer, drag in an HtmlTable control 2) Create a row and a cell for that table 3) Make the width of the cell be 50 px. 4) In the HTML code, add "ms_positioning=GridLayout" to the tag. (In your Designer, you should now see the "grid dots" inside that cell) 5) Now, drag a Button web server control into that cell. 6) Place the Button so that half of it is outside the boundaries of the cell. 7) Run your program. You will notice that the Button appears "on top" of your table, and not inside that cell. How come?

    L 1 Reply Last reply
    0
    • L lnong

      I have a TableCell in a Table (both are "runat=server"). My program dynamically generates ASP:Button controls and puts them inside the HtmlTableCell. The Buttons are put at absolute positions using the "position: absolute; top: 10px; left: 20px" style properties (of couse, the top and left values are different for each different button). Inside my table cell, I use GridLayout instead of FlowLayout (default). Here's is a simple skeletion of my code: <table id=table runat=server> <tr id=row runat=server> <td id=cell runat=server ms_position=GridLayout></td> </tr> </table> There is a function in my C# code that creates the buttons, automatically calculates the top and left positions of each button and then add the button to the table cell. My code for adding looks something like this: Button b = new Button(); b.Style.Add("position", "absolute"); b.Style.Add("top", yValue.ToString()); b.Style.Add("left", xValue.ToString()); FindControl("Main").FindControl("table").FindControl("row").FindControl("cell").Controls.Add(b); So far, everything works well. However, if a Button is placed so that some parts of it is outside the bounds of the TableCell, it just sticks outside of the cell. I want that cell to automatically increase or decrease in width to fit the button. Also, if the cell size reachs a certain length (which I can specify), either the Button should be clipped, or there should be scrollbars inside the cell that will allow me to scroll over to see the whole button. I cannot find a way to do this. My explanation may be confusing, but if you follow these steps, you will see what I am taking about: 1) In the Forms Designer, drag in an HtmlTable control 2) Create a row and a cell for that table 3) Make the width of the cell be 50 px. 4) In the HTML code, add "ms_positioning=GridLayout" to the tag. (In your Designer, you should now see the "grid dots" inside that cell) 5) Now, drag a Button web server control into that cell. 6) Place the Button so that half of it is outside the boundaries of the cell. 7) Run your program. You will notice that the Button appears "on top" of your table, and not inside that cell. How come?

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      Use WebControls, instead of HtmlControls, add the member as protected in your code-behind, then you dont need that FindCOntrol thing. I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02

      L 1 Reply Last reply
      0
      • L leppie

        Use WebControls, instead of HtmlControls, add the member as protected in your code-behind, then you dont need that FindCOntrol thing. I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02

        L Offline
        L Offline
        lnong
        wrote on last edited by
        #3

        At first, I did use an ASP:Table server control. However, I found that I was unable to add any control within the Table's cells by using drag and drop. Then I created a regular HtmlTable. With this I was able to drag and drop anything into the cell. Are you having this problem?

        L 1 Reply Last reply
        0
        • L lnong

          At first, I did use an ASP:Table server control. However, I found that I was unable to add any control within the Table's cells by using drag and drop. Then I created a regular HtmlTable. With this I was able to drag and drop anything into the cell. Are you having this problem?

          L Offline
          L Offline
          leppie
          wrote on last edited by
          #4

          Us hardcore guys, dont use the WebFormsDesigner. Well not the drag'n drop bit, but the source. What I ussaully do is just to drop the control on the page, then switch to sourceview and "move" the textbox to the cell. I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02

          C 1 Reply Last reply
          0
          • L leppie

            Us hardcore guys, dont use the WebFormsDesigner. Well not the drag'n drop bit, but the source. What I ussaully do is just to drop the control on the page, then switch to sourceview and "move" the textbox to the cell. I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02

            C Offline
            C Offline
            ChrisWFL
            wrote on last edited by
            #5

            This is exactly what I do too. The IDE doesn't let you drop controls into a server side table, so I just drag it onto the page, set whatever properties I want, then switch to HTML view and move it into the table code where I want it to live. It's a pain, but it works.

            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