473,473 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

label control not heeding width attribute

I'm trying to block out some text by setting Label width attribute which
renders as a span tag so that all labels for textfields take up the same
amount of space hence the textfields are all aligned but for some reason the
width is being ignored in IE 6 even though it works in Firefox. Is there some
bug associated with this and maybe the Doctype specification?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<style type="text/css">
..waLabel{
width:106px; /* push all textboxes to the right 106px */
margin-right:100px;
border: 1px dotted blue;
}
</style>

The FormView code:
<asp:Label ID="lblFirstName" runat="server" CssClass="waLabel" Text="First
Name" ></asp:Label>
<asp:TextBox ID="tbFirstName" runat="server" CssClass="waTextBox"
Width="180px" Columns="25" MaxLength="25" Text='<%# Bind("FirstName") %>'
</asp:TextBox>

The resulting span code:
<span id="fvRegDetail_lblFirstName" class="waLabel">First Name</span>
<input name="fvRegDetail$tbFirstName" type="text" value="Christopher"
maxlength="25" size="25" id="fvRegDetail_tbFirstName" class="waTextBox"
style="width:180px;" />

thanks for any suggestions on this.

Apr 11 '06 #1
4 6324
I suggest using an HTMLTable to arrange the different controls within
tablecells. Setting the styles on tablecells is more consistent across
browsers that the inline span tag. For example,

<table class="tblClass">
<tr>
<td class="something">
<asp:Label ID="lblFirstName" runat="server" Text="First
Name" ></asp:Label>
</td>
<td class="somethingelse">
<asp:TextBox ID="tbFirstName" runat="server" Columns="25" MaxLength="25"
Text='<%# Bind("FirstName") %>'
</asp:TextBox> </td>
</tr>
</table>

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Dabbler" wrote:
I'm trying to block out some text by setting Label width attribute which
renders as a span tag so that all labels for textfields take up the same
amount of space hence the textfields are all aligned but for some reason the
width is being ignored in IE 6 even though it works in Firefox. Is there some
bug associated with this and maybe the Doctype specification?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<style type="text/css">
.waLabel{
width:106px; /* push all textboxes to the right 106px */
margin-right:100px;
border: 1px dotted blue;
}
</style>

The FormView code:
<asp:Label ID="lblFirstName" runat="server" CssClass="waLabel" Text="First
Name" ></asp:Label>
<asp:TextBox ID="tbFirstName" runat="server" CssClass="waTextBox"
Width="180px" Columns="25" MaxLength="25" Text='<%# Bind("FirstName") %>'
</asp:TextBox>

The resulting span code:
<span id="fvRegDetail_lblFirstName" class="waLabel">First Name</span>
<input name="fvRegDetail$tbFirstName" type="text" value="Christopher"
maxlength="25" size="25" id="fvRegDetail_tbFirstName" class="waTextBox"
style="width:180px;" />

thanks for any suggestions on this.

Apr 11 '06 #2
Thanks Phillip.

I thought of this but was trying to avoid the table solution as I have 50
fields so were talking 50 tr tags + 100 td tags whereas I already have the
style class assigned to the controls. But I think I'm going to have to byte
the bullet. Maybe I can get the search replace with regex to add the tags!
Did I mention I have carpal tunnel syndrome and am trying to minimize typing
;)

"Phillip Williams" wrote:
I suggest using an HTMLTable to arrange the different controls within
tablecells. Setting the styles on tablecells is more consistent across
browsers that the inline span tag. For example,

<table class="tblClass">
<tr>
<td class="something">
<asp:Label ID="lblFirstName" runat="server" Text="First
Name" ></asp:Label>
</td>
<td class="somethingelse">
<asp:TextBox ID="tbFirstName" runat="server" Columns="25" MaxLength="25"
Text='<%# Bind("FirstName") %>'
</asp:TextBox>

</td>
</tr>
</table>

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Dabbler" wrote:
I'm trying to block out some text by setting Label width attribute which
renders as a span tag so that all labels for textfields take up the same
amount of space hence the textfields are all aligned but for some reason the
width is being ignored in IE 6 even though it works in Firefox. Is there some
bug associated with this and maybe the Doctype specification?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<style type="text/css">
.waLabel{
width:106px; /* push all textboxes to the right 106px */
margin-right:100px;
border: 1px dotted blue;
}
</style>

The FormView code:
<asp:Label ID="lblFirstName" runat="server" CssClass="waLabel" Text="First
Name" ></asp:Label>
<asp:TextBox ID="tbFirstName" runat="server" CssClass="waTextBox"
Width="180px" Columns="25" MaxLength="25" Text='<%# Bind("FirstName") %>'
</asp:TextBox>

The resulting span code:
<span id="fvRegDetail_lblFirstName" class="waLabel">First Name</span>
<input name="fvRegDetail$tbFirstName" type="text" value="Christopher"
maxlength="25" size="25" id="fvRegDetail_tbFirstName" class="waTextBox"
style="width:180px;" />

thanks for any suggestions on this.

Apr 11 '06 #3
If I had to arrange 50 fields on a FormView I would use a repeater within the
ItemTemplate and then arrange the rows on the repeater using templates
generated dynamically by building a customized class derived from Itemplate.

Or I would use a detailsView with TemplateFields whose Templates are (again)
composed dynamically like I did in this demo albeit with a GridView:
http://www.webswapp.com/codesamples/.../gridview.aspx

The class I developed in this demo “FormattedTemplate.cs” can be used in a
DetailsView without much of a change.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Dabbler" wrote:
Thanks Phillip.

I thought of this but was trying to avoid the table solution as I have 50
fields so were talking 50 tr tags + 100 td tags whereas I already have the
style class assigned to the controls. But I think I'm going to have to byte
the bullet. Maybe I can get the search replace with regex to add the tags!
Did I mention I have carpal tunnel syndrome and am trying to minimize typing
;)

"Phillip Williams" wrote:
I suggest using an HTMLTable to arrange the different controls within
tablecells. Setting the styles on tablecells is more consistent across
browsers that the inline span tag. For example,

<table class="tblClass">
<tr>
<td class="something">
<asp:Label ID="lblFirstName" runat="server" Text="First
Name" ></asp:Label>
</td>
<td class="somethingelse">
<asp:TextBox ID="tbFirstName" runat="server" Columns="25" MaxLength="25"
Text='<%# Bind("FirstName") %>'
</asp:TextBox>

</td>
</tr>
</table>

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Dabbler" wrote:
I'm trying to block out some text by setting Label width attribute which
renders as a span tag so that all labels for textfields take up the same
amount of space hence the textfields are all aligned but for some reason the
width is being ignored in IE 6 even though it works in Firefox. Is there some
bug associated with this and maybe the Doctype specification?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<style type="text/css">
.waLabel{
width:106px; /* push all textboxes to the right 106px */
margin-right:100px;
border: 1px dotted blue;
}
</style>

The FormView code:
<asp:Label ID="lblFirstName" runat="server" CssClass="waLabel" Text="First
Name" ></asp:Label>
<asp:TextBox ID="tbFirstName" runat="server" CssClass="waTextBox"
Width="180px" Columns="25" MaxLength="25" Text='<%# Bind("FirstName") %>'
></asp:TextBox>
The resulting span code:
<span id="fvRegDetail_lblFirstName" class="waLabel">First Name</span>
<input name="fvRegDetail$tbFirstName" type="text" value="Christopher"
maxlength="25" size="25" id="fvRegDetail_tbFirstName" class="waTextBox"
style="width:180px;" />

thanks for any suggestions on this.

Apr 11 '06 #4
Thanks Phillip all great suggestions, but the fields are not homogenous, need
some radio button lists, checkboxes, dropdown lists and custom layout for
some sections of the page. Otherwise the DetailView would be the solution.

Derived class from ItemTemplate sounds interesting though ;)

"Phillip Williams" wrote:
If I had to arrange 50 fields on a FormView I would use a repeater within the
ItemTemplate and then arrange the rows on the repeater using templates
generated dynamically by building a customized class derived from Itemplate.

Or I would use a detailsView with TemplateFields whose Templates are (again)
composed dynamically like I did in this demo albeit with a GridView:
http://www.webswapp.com/codesamples/.../gridview.aspx

The class I developed in this demo “FormattedTemplate.cs” can be used in a
DetailsView without much of a change.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Dabbler" wrote:
Thanks Phillip.

I thought of this but was trying to avoid the table solution as I have 50
fields so were talking 50 tr tags + 100 td tags whereas I already have the
style class assigned to the controls. But I think I'm going to have to byte
the bullet. Maybe I can get the search replace with regex to add the tags!
Did I mention I have carpal tunnel syndrome and am trying to minimize typing
;)

"Phillip Williams" wrote:
I suggest using an HTMLTable to arrange the different controls within
tablecells. Setting the styles on tablecells is more consistent across
browsers that the inline span tag. For example,

<table class="tblClass">
<tr>
<td class="something">
<asp:Label ID="lblFirstName" runat="server" Text="First
Name" ></asp:Label>
</td>
<td class="somethingelse">
<asp:TextBox ID="tbFirstName" runat="server" Columns="25" MaxLength="25"
Text='<%# Bind("FirstName") %>'
></asp:TextBox>
</td>
</tr>
</table>

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Dabbler" wrote:

> I'm trying to block out some text by setting Label width attribute which
> renders as a span tag so that all labels for textfields take up the same
> amount of space hence the textfields are all aligned but for some reason the
> width is being ignored in IE 6 even though it works in Firefox. Is there some
> bug associated with this and maybe the Doctype specification?
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
>
> <style type="text/css">
> .waLabel{
> width:106px; /* push all textboxes to the right 106px */
> margin-right:100px;
> border: 1px dotted blue;
> }
> </style>
>
> The FormView code:
> <asp:Label ID="lblFirstName" runat="server" CssClass="waLabel" Text="First
> Name" ></asp:Label>
> <asp:TextBox ID="tbFirstName" runat="server" CssClass="waTextBox"
> Width="180px" Columns="25" MaxLength="25" Text='<%# Bind("FirstName") %>'
> ></asp:TextBox>
>
>
> The resulting span code:
> <span id="fvRegDetail_lblFirstName" class="waLabel">First Name</span>
> <input name="fvRegDetail$tbFirstName" type="text" value="Christopher"
> maxlength="25" size="25" id="fvRegDetail_tbFirstName" class="waTextBox"
> style="width:180px;" />
>
> thanks for any suggestions on this.
>

Apr 11 '06 #5

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

Similar topics

3
by: TR | last post by:
Is it possible with CSS to prevent this wrapping alignment with a checkbox with a nested label? This is the label of the checkbox that wraps beneath it I'd prefer it looked like...
7
by: Mike Casey | last post by:
Hello all, I have ASP.NET label controls tied to a datasource (so text will vary in length depending on the record). In IE everything looks great--text is wrapped if needed. In Netscape and...
1
by: NancyASAP | last post by:
I have a label on my ASP.NET form. It has a cssclass that includes a background color. I am dynamically putting text in this label. The text contains some embedded html (I want to display part...
1
by: jack-e | last post by:
Hi, An easy on I'm guessing! How do I restrict the length of a label? I have tried setting the width to say 200px but if the user inputs a continuous line of characters it's doesn't...
6
by: Joe | last post by:
I know that the Literal control will not render a <span> tag so I can not format its text. Other than this, what is the difference betwen the Literal control and the LiteralControl Control? How...
31
by: jcrouse | last post by:
Is there a quick and easy way to change the color of a label controls border from the default black to white? Thank you, John
1
by: Groove | last post by:
I have a typical Repeater that contains a Template (html table). The repeater / template lists many records and in the footer, I'd like to simply SUM up the $$ amounts from all the records in the...
5
by: BobLaughland | last post by:
Hi There, I am trying to get some fields to align on a web page, like this, To: From: Subject: Each of the fields above have a corresponding asp:Textbox control next to it that I cannot...
11
by: Peter Larsen [] | last post by:
Hi, I have two questions related to the Label control. How do i prevent the label from expand the canvas into 2 lines (word wrap) ?? At the moment i set AutoSize to false (to prevent the word...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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...

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.