473,804 Members | 3,526 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do you autosize a Table Cell?

SAL
How do I get a CELL to autosize a round a Control in a HTML Table?

For example, you add a 2 row, 3 column HTML table to your webpage. In the
1st row, you set the colspan=3, then delete the excess columns. Now the 1st
row should look like it has only 1 cell, and the 2nd row has 3 cells. Now
add a Web Forms DataGrid in row, and add a Web Forms Button in the middle
cell of row 2.

Now, when I try to resize the row, I can’t seem to get it to size to the
controls. There always seem to be a gap below or to the left.

Does anyone have any suggestions? I’m fairly new with ASP.net. Here is the
HTML code:

<%@ Page language="c#" Codebehind="Tes t.aspx.cs" AutoEventWireup ="false"
Inherits="TestW ebApp.WebForm1" debug="True"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1 </title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form id="Form1" method="post" runat="server">
<TABLE id="Table2" style="Z-INDEX: 102; LEFT: 20px; POSITION: absolute;
TOP: 16px" cellSpacing="1"
cellPadding="1" width="300" border="1">
<TR>
<TD colSpan="3" style="HEIGHT: 162px">
<asp:DataGrid id="DataGrid2" runat="server" Height="162px"
Width="301px"></asp:DataGrid></TD>
</TR>
<TR>
<TD style="WIDTH: 45px"></TD>
<TD style="WIDTH: 3px">
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button></TD>
<TD></TD>
</TR>
</TABLE>
</form>
</body>
</HTML>

Aug 10 '06 #1
1 6237
Perhaps you need to be setting your tablecell's or your controls width
property based on percentages of total width.

http://msdn2.microsoft.com/en-us/lib...rol.width.aspx

Dont know if its the answer but it might help you find one.

--
Regards

John Timney (MVP)
"SAL" <SA*@discussion s.microsoft.com wrote in message
news:E2******** *************** ***********@mic rosoft.com...
How do I get a CELL to autosize a round a Control in a HTML Table?

For example, you add a 2 row, 3 column HTML table to your webpage. In the
1st row, you set the colspan=3, then delete the excess columns. Now the
1st
row should look like it has only 1 cell, and the 2nd row has 3 cells. Now
add a Web Forms DataGrid in row, and add a Web Forms Button in the middle
cell of row 2.

Now, when I try to resize the row, I can't seem to get it to size to the
controls. There always seem to be a gap below or to the left.

Does anyone have any suggestions? I'm fairly new with ASP.net. Here is
the
HTML code:

<%@ Page language="c#" Codebehind="Tes t.aspx.cs" AutoEventWireup ="false"
Inherits="TestW ebApp.WebForm1" debug="True"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1 </title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form id="Form1" method="post" runat="server">
<TABLE id="Table2" style="Z-INDEX: 102; LEFT: 20px; POSITION: absolute;
TOP: 16px" cellSpacing="1"
cellPadding="1" width="300" border="1">
<TR>
<TD colSpan="3" style="HEIGHT: 162px">
<asp:DataGrid id="DataGrid2" runat="server" Height="162px"
Width="301px"></asp:DataGrid></TD>
</TR>
<TR>
<TD style="WIDTH: 45px"></TD>
<TD style="WIDTH: 3px">
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button></TD>
<TD></TD>
</TR>
</TABLE>
</form>
</body>
</HTML>

Aug 10 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
8459
by: Kai Grossjohann | last post by:
I have a table which contains a top-aligned table cell: .... <tr style="height:40"> ... <td colspan="1" rowspan="2" align="left" valign="top" style="overflow:hidden;"> ...contents.explained.later... </td> ...
23
18656
by: MattB | last post by:
Hello please help, I have a table cell with a div in it. The div has a width of 300px. but when it is rendered it puts extra space into the table cell. Here's the style <style> #treecontainer {
3
10889
by: Thomas Mlynarczyk | last post by:
Hello, How can I make an <a> element (containing text only, styled to be a box with a border) as big as the table cell in which it resides, *without* having specified any width/height (neither fixed nor percentage) for this table cell? Sizing the element to 100% width and height does not work, as the parent element's width and height are not specified. And yet, in this case at least, the width and height of the table cell are very...
2
11270
by: Sugapablo | last post by:
Can anyone help me out with some code to change three table cells (<td>) when one is hovered over? I have a calendar grid where each day is made up of three table cells and I want all three to change color when any of the three are hovered over. I would prefer to do this with pure CSS if possible, but if Javascript is the only way...so be it. --
2
11606
by: ted | last post by:
Hi, Was wondering if it's possible to find the left position of a table cell if the cell is created dynamically. I have a table with a single cell. When a button is clicked, I'd like to add another cell to it, give the cell a class style and then find the cell's left position. Right now I'm using doing this:
5
3901
by: Greg N. | last post by:
Hi folks, I have a table cell with a background image, something like <td background=landscape.jpg height=200></td> The sole purpose of this code is to display the image inside that table cell. It displays just as much of the image as the current cell width allows. The actual cell width is determined by other cells in the same table column and by the current browser window width.
1
3555
by: Thanks | last post by:
I have a routine that is called on Page_Init. It retrieves folder records from a database which I display as Link Buttons in a table cell. I set the table cell's bgcolor to a default color (say black for example). I am dynamically creating the LinkButton controls and adding them into the table cell and I've also hooked up an event handler for each LinkButton's Click event. This all works fine. Now in the Link Button's Click event...
2
65004
by: Yeah | last post by:
Hi, all! I have a question. I am designing a listing similar to a phone book in HTML. Each listing has periods following it, but they must extend to the end of the table cell, and not wrap. Is there any way to prevent the text from 1) wrapping within the table cell and 2) causing the table cell to expand? In other words, the filler periods must flow past the right boundary of the cell (but not be seen). Similar to:
1
16630
by: Bart Lateur | last post by:
I'm trying to put a utton at the bottom (right) of a TD cell, irrespective of what else is in there. Usually, with other HTML block elements, we're told to use position: relative on the parent element, and position: absolute; bottom: 0px;
0
9708
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10340
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10085
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4302
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3828
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2999
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.