Width property not recognized??

B

Barb

I have a problem with my HTML that's rendered by my page. I'm using an
<asp:table> inside of an HTML <table>, and my processing works great except
that I cannot control the width. I'm even lucky enough to only need it to
work w/ IE! It just ignores me. I've tried setting my widths on absolutely
every field, set them using styles instead of just the instrinsic attribute,
tried percents...NOTHING. The only fields that pay attention to anything are
the dropdowns, which adjust to the data within them. The text boxes stay
static, and WAY too big. Here's my code...if you have any suggestions, I
would really appreciate it! THANKS!

ASPX.VB code behind:
--------------------------------------------------------------------------
For Each item In SearchResults.Tables(0).Rows

'Add each line item here
tRow = New TableRow

PhoneNumber.Length = 0 'init phone number field
If item.Areacode <> " " Then
PhoneNumber.Append(item.Areacode)
End If
If item.Phone <> " " Then
If PhoneNumber.Length > 0 Then
PhoneNumber.Append("-")
End If
PhoneNumber.Append(item.Phone)
End If
If PhoneNumber.Length = 0 Then
PhoneNumber.Append(" ")
End If

tCell = New TableCell
tCell = BuildTableCell("", item.CompanyType, False,
9, "percent")
tRow.Cells.Add(tCell)

link.Length = 0 'init string before building
each row.
link.Append("<a
href=""CompanySummary.aspx?companyid=")
link.Append(item.CompanyId.ToString)
link.Append(""">")
link.Append(item.CompanyName.ToString)
link.Append("</a>")

tCell = New TableCell
tCell = BuildTableCell(item.CompanyId.ToString,
link.ToString, False, 9, "percent")
tRow.Cells.Add(tCell)

tCell = New TableCell
tCell = BuildTableCell("", item.Address1, False, 9,
"percent")
tRow.Cells.Add(tCell)

tCell = New TableCell
tCell = BuildTableCell("", item.City, False, 7,
"percent")
tRow.Cells.Add(tCell)

tCell = New TableCell
tCell =BuildTableCell("", item.State, False, 5,
"percent")
tRow.Cells.Add(tCell)

tCell = New TableCell
tCell = BuildTableCell("", item.Zip, False, 6,
"percent")
tRow.Cells.Add(tCell)

tCell = New TableCell
tCell = BuildTableCell("", PhoneNumber.ToString,
False, 9, "percent")
tCell.ColumnSpan = 2
tRow.Cells.Add(tCell)

tCell = New TableCell
tCell = BuildTableCell("", item.Email, False, 9,
"percent")
tRow.Cells.Add(tCell)

tCell = New TableCell
tCell = BuildTableCell("", item.SupplierType, False,
6, "percent")
tRow.Cells.Add(tCell)

tCell = New TableCell
tCell = BuildTableCell("", item.Website, False, 9,
"percent")
tRow.Cells.Add(tCell)

tCell = New TableCell
tCell = BuildTableCell("", item.PrefAgent, False, 7,
"percent")
tRow.Cells.Add(tCell)

tCell = New TableCell
tCell = BuildTableCell("", item.Branchname, False,
9, "percent")
tRow.Cells.Add(tCell)

tCell = New TableCell
tCell = BuildTableCell("", item.Status, False, 6,
"percent")
tRow.Cells.Add(tCell)

'Add the whole row now.
tRow.CssClass = "TableList"
tRow.Attributes.Add("BgColor", "#F2F3E4")
tblMainContent.Rows.Add(tRow)
End If
Next

Public Function BuildTableCell(ByVal id As String, _
ByVal text As String, _
ByVal viewState As Boolean, _
ByVal width As Integer, _
ByVal widthType As String) As TableCell

Dim cell As TableCell = New TableCell
'add an ID to the cell if specified.
If id <> "" Then
cell.ID = id
End If
cell.Text = text

Dim widthUnit As String
If widthType = "pixel" Then
widthUnit = "px"
ElseIf widthType = "percent" Then
widthUnit = "%"
End If

cell.Style.Add("Width", width.ToString & widthUnit)
'cell.Attributes.Add("Width", width.ToString & widthUnit)
cell.EnableViewState = viewState
Return cell

End Function
-----------------------------------------
ASPX page:
-----------------------------------------

<table style="BORDER-RIGHT: teal 1px solid; BORDER-TOP: teal 1px solid;
BORDER-LEFT: teal 1px solid; BORDER-BOTTOM: teal 1px solid; width:600px"
borderColor="teal" cellSpacing="0" cellPadding="0">
<tr>
<td noWrap align="left" colSpan="2" style="WIDTH:600px; HEIGHT:25px;
FONT-WEIGHT: bolder; FONT-SIZE: 12pt; COLOR: white; FONT-FAMILY: Tahoma,
Verdana, Arial; BACKGROUND-COLOR: teal">
<asp:label id="lblCornerText" runat="server">
Company Search</asp:label></td>
</tr>
<tr vAlign="top"> <!--one big row that holds all of the page below the
headers. -->
<!--The first <td> tag is the left nav menu, the 2nd one is the page
content -->
<td style="WIDTH: 86px" vAlign="top" bgColor="teal">
<script language="javascript">
fcnNewMenu2(true);
</script>
<hr class="ButtonDividerSmall" runat="server">
</hr>
<br>
<asp:placeholder id="phLeftNavSearch" Runat="server"></asp:placeholder>
<td>
<asp:table CssClass="TableList" id="tblMainContent" cellSpacing="1"
cellPadding="0" BorderWidth="0"
Runat="server" style="Width:520px">
<asp:TableRow CssClass="TableListHead" id="tRowHeading"
VerticalAlign="top" runat="server">
<asp:TableCell style="WIDTH: 9%" Runat="server">Type</asp:TableCell>
<asp:TableCell style="WIDTH: 9%"
Runat="server">Company Name</asp:TableCell>
<asp:TableCell style="WIDTH: 9%" Runat="server">Delivery
Address</asp:TableCell>
<asp:TableCell style="WIDTH: 7%" Runat="server">City</asp:TableCell>
<asp:TableCell style="WIDTH: 5%" Runat="server">State</asp:TableCell>
<asp:TableCell style="WIDTH: 6%" Runat="server">Zip</asp:TableCell>
<asp:TableCell style="WIDTH: 9%" ColumnSpan="2"
Runat="server">Phone</asp:TableCell>
<asp:TableCell style="WIDTH: 9%" Runat="server">Email</asp:TableCell>
<asp:TableCell style="WIDTH: 6%" Runat="server">Supplier<br>
Type</asp:TableCell>
<asp:TableCell style="WIDTH: 9%" Runat="server">Website</asp:TableCell>
<asp:TableCell style="WIDTH: 7%" Runat="server">Preferred
Agent</asp:TableCell>
<asp:TableCell style="WIDTH: 9%" Runat="server">Branch</asp:TableCell>
<asp:TableCell style="WIDTH: 6%" Runat="server">Status</asp:TableCell>
</asp:TableRow>

<asp:tablerow style="BORDER-BOTTOM: silver 1px solid">
<asp:TableCell style="WIDTH: 9%" Runat="server">
<asp:dropdownlist id="ddCompanyType" Runat="server"></asp:dropdownlist>
</asp:TableCell>
<asp:TableCell style="WIDTH: 9%" Runat="server">
<asp:textbox id="txtCompanyName" Runat="server"></asp:textbox>
</asp:TableCell>
<asp:TableCell style="WIDTH: 9%" Runat="server">
<asp:textbox id="txtAddress" Runat="server"></asp:textbox>
</asp:TableCell>
<asp:TableCell style="WIDTH: 7%" Runat="server">
<asp:textbox id="txtCity" Runat="server"></asp:textbox>
</asp:TableCell>
<asp:TableCell style="WIDTH: 5%" Runat="server">
<asp:textbox id="txtState" Runat="server"></asp:textbox>
</asp:TableCell>
<asp:TableCell style="WIDTH: 6%" Runat="server">
<asp:textbox id="txtZip" Runat="server"></asp:textbox>
</asp:TableCell>
<asp:TableCell style="WIDTH: 3%" Runat="server">
<asp:textbox id="txtAreaCode" Runat="server"></asp:textbox>
</asp:TableCell>
<asp:TableCell style="WIDTH: 6%" Runat="server">
<asp:textbox id="txtPhone" Runat="server"></asp:textbox>
</asp:TableCell>
<asp:TableCell style="WIDTH: 9%" Runat="server">
<asp:textbox id="txtEmail" Runat="server"></asp:textbox>
</asp:TableCell>
<asp:TableCell style="WIDTH: 6%" Runat="server">
<asp:dropdownlist id="ddSupplierType" Runat="server"></asp:dropdownlist>
</asp:TableCell>
<asp:TableCell style="WIDTH: 9%" Runat="server">
<asp:textbox id="txtWebsite" Runat="server"></asp:textbox>
</asp:TableCell>
<asp:TableCell style="WIDTH: 7%" Runat="server">
<asp:dropdownlist id="ddPrefAgent" Runat="server"></asp:dropdownlist>
</asp:TableCell>
<asp:TableCell style="WIDTH: 9%" Runat="server">
<asp:dropdownlist id="ddBranch" Runat="server"></asp:dropdownlist>
</asp:TableCell>
<asp:TableCell style="WIDTH: 6%" Runat="server">
<asp:dropdownlist id="ddStatus" Runat="server"></asp:dropdownlist>
</asp:TableCell>
</asp:tablerow>
</asp:table>
</td>
</tr>
</table>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top