By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,364 Members | 1,580 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,364 IT Pros & Developers. It's quick & easy.

Problem rendering a 100% width textbox on IE using XHTML 1.0 stand

P: n/a
Hello all,

I've created the following ASP.NET code sample which, when rendered,
displays a 100% textbox within a single cell table. The problem is that
Internet Explorer (6 or 7) truncates the right-hand edge of the textbox. The
textbox renders correctly on Firefox and Netscape.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb"
Inherits="Content_test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="frmMyForm" runat="server">
<table style="width: 100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<asp:TextBox ID="txtMyText" runat="server"
Width="100%"></asp:TextBox>
</td>
</tr>
</table>
</form>
</body>
</html>

However, if the following DOCTYPE tag is used instead of the XHTML one
above...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

.... then IE renders the textbox correctly also.

Can anyone tell me why this happens? Why is the textbox rendered
differently between the two standards and why does only IE have the problem?

XHTML 1.0 appears to be the default DOCTYPE tag added to all .aspx pages (in
VS 2005/.NET 2.0), so I assume this is the latest standard we should be using.

Is there anything that can be done to make XHTML 1.0 work with IE so that
the textbox will display how I expect it to?

Any help appreciated.

Thanks,
Wayne.
May 2 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
please read about w3c standards especially widths. setting xhtml set IE
in strict mode where it tries to follow the standards.

the main point to understand is when you set the width of an html
element, you are setting the width of the content. the border and margin
are outside the content.

in your case you are setting a textbox width to its parent width, but
the margin and border cause it to be offset. then the right hand side
overflows the parent. in strict mode IE truncates (overflow:hidden), in
non-strict it resizes the parent.

-- bruce (sqlwork.com)

wclarke101 wrote:
Hello all,

I've created the following ASP.NET code sample which, when rendered,
displays a 100% textbox within a single cell table. The problem is that
Internet Explorer (6 or 7) truncates the right-hand edge of the textbox. The
textbox renders correctly on Firefox and Netscape.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb"
Inherits="Content_test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="frmMyForm" runat="server">
<table style="width: 100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<asp:TextBox ID="txtMyText" runat="server"
Width="100%"></asp:TextBox>
</td>
</tr>
</table>
</form>
</body>
</html>

However, if the following DOCTYPE tag is used instead of the XHTML one
above...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

... then IE renders the textbox correctly also.

Can anyone tell me why this happens? Why is the textbox rendered
differently between the two standards and why does only IE have the problem?

XHTML 1.0 appears to be the default DOCTYPE tag added to all .aspx pages (in
VS 2005/.NET 2.0), so I assume this is the latest standard we should be using.

Is there anything that can be done to make XHTML 1.0 work with IE so that
the textbox will display how I expect it to?

Any help appreciated.

Thanks,
Wayne.
May 2 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.