473,402 Members | 2,061 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,402 software developers and data experts.

Size vs Width in ASP.net

In HTML - for a textbox (input), I would use the 'Size' Attribute
In an ASP.Net TextBox - I use 'Width' - - (like 200px)

However, for other browsers - Other than IE - the size attribute isn't
added - - I can add it, but in able to get the sizes correct, I need some
corresponding algorithm for Width vs Size - -

Does anyone know how the Size attribute is attained?
Let's say I wanted to add a Size attribute to a textbox in page_Load - - I
wanted the size to equal the 200px width I use - -

How does that equate?
Nov 19 '05 #1
2 16476
I would think an algorithm would not be a straight forward answer. Here is
why I would think so:
Width, when using pixels(px) is a fixed length: at 1pt = 1/72 inch, 200px
would aprox 2.78 inches. The Size attribute is the number of characters
(i.e. size=50 means 50 characters wide) so it is dependent on your font type
and size. And unless you use a fixed font size, as client inceases/decreases
browser font the text box, using size attribute, will grow/shrink
accordingly...and client can still override that. Further complicating that
is that font "size" really is applicable to the height of the font, not the
width. The width is "proportional" and only relative to the height.
Based on that it's easiest to set size = number of characters you allow as
input or at least the number you will show (the rest will ticker tape).

You can just set it directly in the html code for the page. Example:
<asp:textbox id="Textbox1" runat="server" Width="200px"
Size="28"></asp:textbox>
This assumes 10 pt Verdana font, you could fit aprox 28 characters into a
200px textbox, so Size=28

In code you could do the same. Example:
Textbox1.Attributes.Add("Size","28)

Here are some measurements equivalents. But again, for a font they really
only apply to the height.
in: inches -- 1 inch is equal to 2.54 centimeters.
pt: points -- the points used by CSS2 are equal to 1/72th of an inch.
pc: picas -- 1 pica is equal to 12 points.
px: pixels -- typical 96 or 72 pixels per inch (ppi)

Perhaps you could use the bitmap and graphics objects in the framework to
derive this. I know you can use them to measure a string of a given font
and size and get the pixels.

"Elmo Watson" <sp*****@nospam.yahoo.com> wrote in message
news:uX**************@TK2MSFTNGP14.phx.gbl...
In HTML - for a textbox (input), I would use the 'Size' Attribute
In an ASP.Net TextBox - I use 'Width' - - (like 200px)

However, for other browsers - Other than IE - the size attribute isn't
added - - I can add it, but in able to get the sizes correct, I need some
corresponding algorithm for Width vs Size - -

Does anyone know how the Size attribute is attained?
Let's say I wanted to add a Size attribute to a textbox in page_Load - - I
wanted the size to equal the 200px width I use - -

How does that equate?


Nov 19 '05 #2
I would think an algorithm would not be a straight forward answer. Here is
why I would think so:
Width, when using pixels(px) is a fixed length: at 1pt = 1/72 inch, 200px
would aprox 2.78 inches. The Size attribute is the number of characters
(i.e. size=50 means 50 characters wide) so it is dependent on your font type
and size. And unless you use a fixed font size, as client inceases/decreases
browser font the text box, using size attribute, will grow/shrink
accordingly...and client can still override that. Further complicating that
is that font "size" really is applicable to the height of the font, not the
width. The width is "proportional" and only relative to the height.
Based on that it's easiest to set size = number of characters you allow as
input or at least the number you will show (the rest will ticker tape).

You can just set it directly in the html code for the page. Example:
<asp:textbox id="Textbox1" runat="server" Width="200px"
Size="28"></asp:textbox>
This assumes 10 pt Verdana font, you could fit aprox 28 characters into a
200px textbox, so Size=28

In code you could do the same. Example:
Textbox1.Attributes.Add("Size","28)

Here are some measurements equivalents. But again, for a font they really
only apply to the height.
in: inches -- 1 inch is equal to 2.54 centimeters.
pt: points -- the points used by CSS2 are equal to 1/72th of an inch.
pc: picas -- 1 pica is equal to 12 points.
px: pixels -- typical 96 or 72 pixels per inch (ppi)

Perhaps you could use the bitmap and graphics objects in the framework to
derive this. I know you can use them to measure a string of a given font
and size and get the pixels.

"Elmo Watson" <sp*****@nospam.yahoo.com> wrote in message
news:uX**************@TK2MSFTNGP14.phx.gbl...
In HTML - for a textbox (input), I would use the 'Size' Attribute
In an ASP.Net TextBox - I use 'Width' - - (like 200px)

However, for other browsers - Other than IE - the size attribute isn't
added - - I can add it, but in able to get the sizes correct, I need some
corresponding algorithm for Width vs Size - -

Does anyone know how the Size attribute is attained?
Let's say I wanted to add a Size attribute to a textbox in page_Load - - I
wanted the size to equal the 200px width I use - -

How does that equate?


Nov 19 '05 #3

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

Similar topics

35
by: wired | last post by:
Hi, I've just taught myself C++, so I haven't learnt much about style or the like from any single source, and I'm quite styleless as a result. But at the same time, I really want nice code and I...
12
by: J L | last post by:
When I fill a listview, I resize the columns to fit the data. I need to know if the data will fit vertically or if there will be a vertical scroll bar. I need to know this so I can allow for it on...
7
by: Daniel Kaplan | last post by:
I have the item below at the top of my style sheet. And it seems that the font-szie is ignored. I know that my linked style sheet is being read, and used because if I remove the font-family line,...
14
by: Galen Somerville | last post by:
My current screen resolution is set to 1024 x 768. My form size always comes up as 1032 x 748. I have tried the help sample ' Retrieve the working rectangle from the Screen class ' using the...
11
by: Parrot | last post by:
Is there any routine I can call to reduce the size of an image file after uploading a file from a client. I am looking to reduce file sizes programmatically using C# in my web page after uploading....
2
by: Brian Tkatch | last post by:
Not sure if this is the way it's supposed to be, but after a Layout event on an MDI form, the form's new width is set, but the MDIClient's width is not. As an example, start a new Windows...
2
by: Dominique | last post by:
Hello, Im want to fix the width of a dashboard. I have a field which has a field (in this dashboard on the left part of my screen) which could be long and make the right side of the screen out...
7
by: carterweb | last post by:
This is how I do it now. 1. Determine the dimensions of the rectangle. 2. Set a my font size to a fixed maximum size. 3. Apply the font my string and measure the string using the graphics...
6
by: Miro | last post by:
Is there a way to / or a mathematical formula to see if a font size is 'too big' for a label. I have a label that is docked to 'fill' a form, and I want to resize that font based on the width...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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
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...
0
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 project—planning, coding, testing,...
0
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...

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.