473,587 Members | 2,580 Online
Bytes | Software Development & Data Engineering Community
+ 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="lblFirstNam e" runat="server" CssClass="waLab el" Text="First
Name" ></asp:Label>
<asp:TextBox ID="tbFirstName " runat="server" CssClass="waTex tBox"
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="fvRegDeta il$tbFirstName" type="text" value="Christop her"
maxlength="25" size="25" id="fvRegDetail _tbFirstName" class="waTextBo x"
style="width:18 0px;" />

thanks for any suggestions on this.

Apr 11 '06 #1
4 6332
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="somethin g">
<asp:Label ID="lblFirstNam e" runat="server" Text="First
Name" ></asp:Label>
</td>
<td class="somethin gelse">
<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="lblFirstNam e" runat="server" CssClass="waLab el" Text="First
Name" ></asp:Label>
<asp:TextBox ID="tbFirstName " runat="server" CssClass="waTex tBox"
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="fvRegDeta il$tbFirstName" type="text" value="Christop her"
maxlength="25" size="25" id="fvRegDetail _tbFirstName" class="waTextBo x"
style="width:18 0px;" />

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="somethin g">
<asp:Label ID="lblFirstNam e" runat="server" Text="First
Name" ></asp:Label>
</td>
<td class="somethin gelse">
<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="lblFirstNam e" runat="server" CssClass="waLab el" Text="First
Name" ></asp:Label>
<asp:TextBox ID="tbFirstName " runat="server" CssClass="waTex tBox"
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="fvRegDeta il$tbFirstName" type="text" value="Christop her"
maxlength="25" size="25" id="fvRegDetail _tbFirstName" class="waTextBo x"
style="width:18 0px;" />

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 “FormattedTem plate.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="somethin g">
<asp:Label ID="lblFirstNam e" runat="server" Text="First
Name" ></asp:Label>
</td>
<td class="somethin gelse">
<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="lblFirstNam e" runat="server" CssClass="waLab el" Text="First
Name" ></asp:Label>
<asp:TextBox ID="tbFirstName " runat="server" CssClass="waTex tBox"
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="fvRegDeta il$tbFirstName" type="text" value="Christop her"
maxlength="25" size="25" id="fvRegDetail _tbFirstName" class="waTextBo x"
style="width:18 0px;" />

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 “FormattedTem plate.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="somethin g">
<asp:Label ID="lblFirstNam e" runat="server" Text="First
Name" ></asp:Label>
</td>
<td class="somethin gelse">
<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="lblFirstNam e" runat="server" CssClass="waLab el" Text="First
> Name" ></asp:Label>
> <asp:TextBox ID="tbFirstName " runat="server" CssClass="waTex tBox"
> 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="fvRegDeta il$tbFirstName" type="text" value="Christop her"
> maxlength="25" size="25" id="fvRegDetail _tbFirstName" class="waTextBo x"
> style="width:18 0px;" />
>
> 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
13138
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 this, with a flush left margin:
7
2918
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 Opera, the text extends horizontally and does not wrap. Any ideas would be most appreciated! Thanks,
1
1694
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 of label contents as a list so it uses <ul> and <li>). The format of the string assigned to label text looks like this: "An error...
1
1455
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 wrap.
6
6924
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 about a LiteralControl and a Label? Other than the lack of being able to format the Literal control's text, I don't see much of a difference in...
31
7192
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
1796
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 repeater. Easy enough. So I tried to place a Label control in the footer and fill the Text of the label from code. I get the label is not...
5
11770
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 get to lign up. I have this code,
11
11483
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 wrap from happening) and Anchor to Left, Right (to enable the with autosize). How do i prevent a tool-tip from happening if the text is to large...
0
7918
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, well explore What is ONU, What Is Router, ONU & Routers main...
0
8206
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8340
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...
1
7967
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6621
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 projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5392
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...
1
2353
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
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1185
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...

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.