How do I place controls "inside" a table cell

How do I place controls "inside" a table cell

Post by James » Fri, 14 Mar 2003 04:41:32



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 <td> 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?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

 
 
 

1. How do I place controls "inside" a table cell?

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 <td> 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?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

2. professinal books

3. """"""""""""""""""""""

4. MER-B/Opportunity Update - June 25, 2003

5. "in 24 hours" - events for controls inside asp:table not available?

6. amiga emulator

7. Best profile for closure""""""""""Windows Server Engineer""""""""" @ Sacramento CA for 1year project

8. Beginners Question: Temporary Variables

9. """"""""""Oracle Portal Developer Position"""""""" @ Dallas TX for 6+ months

10. no control generating <A HREF="" target="" onclick=""

11. Help with "this.Controls.Clear();" preceding "this.Controls.Add( newFolder );".

12. "Quote Values Differently inside a '<% "Value" %>' block

13. Any available "grid-like" control in .NET that allow string wrapping in cells???