473,779 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 11804
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********@hotm ail.com
http://www.nathansokalski.com/

"BobLaughla nd" <pe************ *@gmail.comwrot e in message
news:11******** **************@ 57g2000hsv.goog legroups.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...@hot mail.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...@hotm ail.comhttp://www.nathansokal ski.com/

"BobLaughla nd" <peter.mcclym.. .@gmail.comwrot e in message

news:11******** **************@ 57g2000hsv.goog legroups.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="EmailEnt ry">
<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.comwrot e:
On Sep 4, 11:38 am, "Nathan Sokalski" <njsokal...@hot mail.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...@hotm ail.comhttp://www.nathansokal ski.com/
"BobLaughla nd" <peter.mcclym.. .@gmail.comwrot e in message
news:11******** **************@ 57g2000hsv.goog legroups.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="EmailEnt ry">
<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:labeldoe s 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...@hot mail.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...@hot mail.comhttp://www.nathansokal ski.com/

"BobLaughlan d" <peter.mcclym.. .@gmail.comwrot e in message

news:11******* *************** @57g2000hsv.goo glegroups.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:TextBo x 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="EmailEnt ry">
<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:

..FixedWidthLab el{display:inli ne-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="Fixed WidthLabel"/>

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********@hotm ail.com
http://www.nathansokalski.com/

"BobLaughla nd" <pe************ *@gmail.comwrot e in message
news:11******** **************@ 57g2000hsv.goog legroups.com...
On Sep 4, 11:38 am, "Nathan Sokalski" <njsokal...@hot mail.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...@hot mail.comhttp://www.nathansokal ski.com/

"BobLaughlan d" <peter.mcclym.. .@gmail.comwrot e in message

news:11******* *************** @57g2000hsv.goo glegroups.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="EmailEnt ry">
<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
2933
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,
2
3234
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 Control (which I'm sure is not done correctly) and get errors as I try to execute it. What I want to do is take all the data from between the ItemTemplate tags and put a control there. The I hope to be able to hide all the user
1
6428
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 binding it to a repeater control. This repeater control has multiple text boxes and buttons. Can you please tell me how can i do paging in this case ? I'm posting my code below. The problem is that if i click on "AdjustThisAd" button, it opens...
0
2285
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 chkAll. I simply want to have chkAll be checked if every item in the repeater has its checkbox checked. In the code behind page, I can access the checked property of chkReconciled by doing the following: Dim CurrentCheckBox As CheckBox...
2
2587
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 control to Top, I've never needed to change its height and vice-versa. But, now I would like to do this and I'm not sure what the "right way" is to perform this. Should I just add an extra container (panel, usercontrol, etc) around the control...
1
1744
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." What control, or line of Code is causing the error? here is the offending code :
0
2573
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 link (1,2,3 so on). The code can be found in SubscriptionCart.aspx.cs. Default.aspx ------------
0
9851
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: element". Here am posting the whole .ascx page. Will you please let me know how can i remove this error.
0
2313
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 form it is being used. I am using table in the listview control for formating purpose. In this table I want to hide a column. Is it posible to hide the column?. I am facing the problem because I cant catch the row its showing null values. ...
0
9632
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9471
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10302
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10136
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10071
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9925
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7478
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6723
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4036
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

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.