473,326 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Cannot control the width of the label control

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,

<asp:Label Runat="server" Width="100px" ID="Label6">To: </
asp:Label>
<asp:TextBox ID="Textbox1" Runat="server" Width="200px" />
<asp:Label Runat="server" ID="Label7" ForeColor=red Width="5px">*</
asp:Label>

So that means I have tried to tell it that I want the asp:label
control to be 100 pixels wide, but it seems to shrink the label width
to fit the text.

Please help.

Sep 3 '07 #1
5 11709
I once had that problem too, and I found that the problem is that the
element must also be a block element. To solve your problem, add the
following attribute:

style="display:inline-block;"

This will solve your problem. I add this attribute to many of my Label
controls when creating input forms, because it is more efficient than making
a table if you only have a few fields (not to mention specifying the
dimensions of table cells has given me more frustration than any other
layout aspect). Good Luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"BobLaughland" <pe*************@gmail.comwrote in message
news:11**********************@57g2000hsv.googlegro ups.com...
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,

<asp:Label Runat="server" Width="100px" ID="Label6">To: </
asp:Label>
<asp:TextBox ID="Textbox1" Runat="server" Width="200px" />
<asp:Label Runat="server" ID="Label7" ForeColor=red Width="5px">*</
asp:Label>

So that means I have tried to tell it that I want the asp:label
control to be 100 pixels wide, but it seems to shrink the label width
to fit the text.

Please help.

Sep 3 '07 #2
On Sep 4, 11:38 am, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
I once had that problem too, and I found that the problem is that the
element must also be a block element. To solve your problem, add the
following attribute:

style="display:inline-block;"

This will solve your problem. I add this attribute to many of my Label
controls when creating input forms, because it is more efficient than making
a table if you only have a few fields (not to mention specifying the
dimensions of table cells has given me more frustration than any other
layout aspect). Good Luck!
--
Nathan Sokalski
njsokal...@hotmail.comhttp://www.nathansokalski.com/

"BobLaughland" <peter.mcclym...@gmail.comwrote in message

news:11**********************@57g2000hsv.googlegro ups.com...
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,
<asp:Label Runat="server" Width="100px" ID="Label6">To: </
asp:Label>
<asp:TextBox ID="Textbox1" Runat="server" Width="200px" />
<asp:Label Runat="server" ID="Label7" ForeColor=red Width="5px">*</
asp:Label>
So that means I have tried to tell it that I want the asp:label
control to be 100 pixels wide, but it seems to shrink the label width
to fit the text.
Please help.- Hide quoted text -

- Show quoted text -
Great, you are on the money.

I have a CSS file which I want to put it into. How do I do that?

The label I want to control is wrapped in side a div.

<div class="EmailEntry">
<asp:Label Runat="server" ID="Label1" >To: </asp:Label>
<asp:TextBox ID="ToField" Runat="server" Width=80% />
..............
.............
</div>

So if I put this into my css why does it not work?

div.emailentry label
{
display: inline-block; /* or inline block, which ever one you
think looks better */
width: 80px;
}

I have also tried 'div.emailentry label1' but that didn't work either.

Sep 4 '07 #3
On 4 , 03:27, BobLaughland <peter.mcclym...@gmail.comwrote:
On Sep 4, 11:38 am, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
I once had that problem too, and I found that the problem is that the
element must also be a block element. To solve your problem, add the
following attribute:
style="display:inline-block;"
This will solve your problem. I add this attribute to many of my Label
controls when creating input forms, because it is more efficient than making
a table if you only have a few fields (not to mention specifying the
dimensions of table cells has given me more frustration than any other
layout aspect). Good Luck!
--
Nathan Sokalski
njsokal...@hotmail.comhttp://www.nathansokalski.com/
"BobLaughland" <peter.mcclym...@gmail.comwrote in message
news:11**********************@57g2000hsv.googlegro ups.com...
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,
<asp:Label Runat="server" Width="100px" ID="Label6">To: </
asp:Label>
<asp:TextBox ID="Textbox1" Runat="server" Width="200px" />
<asp:Label Runat="server" ID="Label7" ForeColor=red Width="5px">*</
asp:Label>
So that means I have tried to tell it that I want the asp:label
control to be 100 pixels wide, but it seems to shrink the label width
to fit the text.
Please help.- Hide quoted text -
- Show quoted text -

Great, you are on the money.

I have a CSS file which I want to put it into. How do I do that?

The label I want to control is wrapped in side a div.

<div class="EmailEntry">
<asp:Label Runat="server" ID="Label1" >To: </asp:Label>
<asp:TextBox ID="ToField" Runat="server" Width=80% />
.............
............
</div>

So if I put this into my css why does it not work?

div.emailentry label
{
display: inline-block; /* or inline block, which ever one you
think looks better */
width: 80px;

}

I have also tried 'div.emailentry label1' but that didn't work either.
Try this:

<style>
div.EmailEntry span
{
width: 80px;
float:left;
}
div.EmailEntry input
{
margin-left: 100px; /*indent from left side*/
display:block;
width: 80%;
}
</style>

Mykola
http://marss.co.ua

Sep 4 '07 #4
<asp:labeldoes not generate a <label(for which there is no asp.net
control) but rather a <span>.

-- bruce (sqlwork.com)

BobLaughland wrote:
On Sep 4, 11:38 am, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
>I once had that problem too, and I found that the problem is that the
element must also be a block element. To solve your problem, add the
following attribute:

style="display:inline-block;"

This will solve your problem. I add this attribute to many of my Label
controls when creating input forms, because it is more efficient than making
a table if you only have a few fields (not to mention specifying the
dimensions of table cells has given me more frustration than any other
layout aspect). Good Luck!
--
Nathan Sokalski
njsokal...@hotmail.comhttp://www.nathansokalski.com/

"BobLaughland" <peter.mcclym...@gmail.comwrote in message

news:11**********************@57g2000hsv.googlegr oups.com...
>>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,
<asp:Label Runat="server" Width="100px" ID="Label6">To: </
asp:Label>
<asp:TextBox ID="Textbox1" Runat="server" Width="200px" />
<asp:Label Runat="server" ID="Label7" ForeColor=red Width="5px">*</
asp:Label>
So that means I have tried to tell it that I want the asp:label
control to be 100 pixels wide, but it seems to shrink the label width
to fit the text.
Please help.- Hide quoted text -
- Show quoted text -

Great, you are on the money.

I have a CSS file which I want to put it into. How do I do that?

The label I want to control is wrapped in side a div.

<div class="EmailEntry">
<asp:Label Runat="server" ID="Label1" >To: </asp:Label>
<asp:TextBox ID="ToField" Runat="server" Width=80% />
.............
............
</div>

So if I put this into my css why does it not work?

div.emailentry label
{
display: inline-block; /* or inline block, which ever one you
think looks better */
width: 80px;
}

I have also tried 'div.emailentry label1' but that didn't work either.
Sep 4 '07 #5
My recommendation would be to use a CSS class, like the following:

..FixedWidthLabel{display:inline-block;}

And then apply that class to each of the Label controls you want by using
the CssClass property, such as:

<asp:Label Runat="server" Width="100px" ID="Label6" Text="To:"
CssClass="FixedWidthLabel"/>

If you would like to place the width in the CSS class as well, you may want
to do that as well, since it sounds like you want them all to be the same
width, but that is obviously your choice. Hopefully this helps. Good Luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"BobLaughland" <pe*************@gmail.comwrote in message
news:11**********************@57g2000hsv.googlegro ups.com...
On Sep 4, 11:38 am, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
>I once had that problem too, and I found that the problem is that the
element must also be a block element. To solve your problem, add the
following attribute:

style="display:inline-block;"

This will solve your problem. I add this attribute to many of my Label
controls when creating input forms, because it is more efficient than
making
a table if you only have a few fields (not to mention specifying the
dimensions of table cells has given me more frustration than any other
layout aspect). Good Luck!
--
Nathan Sokalski
njsokal...@hotmail.comhttp://www.nathansokalski.com/

"BobLaughland" <peter.mcclym...@gmail.comwrote in message

news:11**********************@57g2000hsv.googlegr oups.com...
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,
<asp:Label Runat="server" Width="100px" ID="Label6">To: </
asp:Label>
<asp:TextBox ID="Textbox1" Runat="server" Width="200px" />
<asp:Label Runat="server" ID="Label7" ForeColor=red Width="5px">*</
asp:Label>
So that means I have tried to tell it that I want the asp:label
control to be 100 pixels wide, but it seems to shrink the label width
to fit the text.
Please help.- Hide quoted text -

- Show quoted text -

Great, you are on the money.

I have a CSS file which I want to put it into. How do I do that?

The label I want to control is wrapped in side a div.

<div class="EmailEntry">
<asp:Label Runat="server" ID="Label1" >To: </asp:Label>
<asp:TextBox ID="ToField" Runat="server" Width=80% />
.............
............
</div>

So if I put this into my css why does it not work?

div.emailentry label
{
display: inline-block; /* or inline block, which ever one you
think looks better */
width: 80px;
}

I have also tried 'div.emailentry label1' but that didn't work either.

Sep 4 '07 #6

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

Similar topics

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...
2
by: tshad | last post by:
This is related to my other Hiding datalistitems problem that I can't seem to solve. I have tried different methods which all seem to work only partially. I decided to try to use a User...
1
by: ratnakarp | last post by:
Hi, I have a search text box. The user enters the value in the text box and click on enter button. In code behind on button click i'm writing the code to get the values from the database and...
0
by: Keith | last post by:
I have a repeater control that contains a HeaderTemplate and an ItemTemplate. Each item contains a checkbox with an ID of chkReconciled, and the header contains a single checkbox with an ID of...
2
by: illegal.prime | last post by:
I'm surprised that I'm only know discovering this problem, but I suppose I've never needed to change the dimension that is opposite to the docking of the control. That is, when I've docked a...
1
by: =?Utf-8?B?am9uZWZlcg==?= | last post by:
I keep getting the message after I converted a regular aspx page to now be based on a master page: "Only Content controls are allowed directly in a content page that contains Content controls."...
0
by: Eugene Anthony | last post by:
The problem with my coding is that despite removing the records stored in the array list, the rptPages repeater control is still visible. The rptPages repeater control displayes the navigation...
0
by: pankajprakash | last post by:
Hi all I am using the Ajax control toolkit and want to the fill the gridview but at the time of rendering it occurs the error "Sys.ArgumentNullException: Value cannot be null. Parameter name:...
0
by: bharathreddy | last post by:
Hi All, I am using a listview control in my usercontrol so that it can be used in more than one form. This user control has one column extraw, so i want to make it invisible depending on the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.