473,597 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Specifying Width and Height properties as percentages

I am sure most of us have enough experience with HTML to know that most HTML
elements allow you to specify the width and/or height attributes as
percentages. However, I have noticed that when setting properties for an
object on a webform (such as a TableCell) programmaticall y, the only way to
do this is by using the Add method of the Attribute property as follows:

webformobject.A ttributes.Add(" width", CStr(33) & "%")
Even though this is not complicated to do, I would like to know why these
objects do not have a direct property. Isn't one of the advantages of using
ASP.NET supposed to be having it generate the code/attributes for us? If
anyone knows a reason why the objects were designed this way, I would like
to know. Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/
Nov 19 '05 #1
2 1331
Possibly because the developer think that it's more common to dynamically
specifing the exact dimension than use percentage.

Consider when you're adding a HtmlControl, the more common way to use the
percentage is to specify the exact string:
MyControl.Attri bute.Add("width ", "50%");

If the user want to use exact dimension, he may need to do some calculation
first, so making the properties integer will be more convinent(I doubt that
if according to W3C decimal/double is legal value for width/height, they
will be chosen instead).

"Nathan Sokalski" <nj********@hot mail.com> ¼¶¼g©ó¶l¥ó·s»D: %2************* ***@TK2MSFTNGP1 2.phx.gbl...
I am sure most of us have enough experience with HTML to know that most
HTML elements allow you to specify the width and/or height attributes as
percentages. However, I have noticed that when setting properties for an
object on a webform (such as a TableCell) programmaticall y, the only way to
do this is by using the Add method of the Attribute property as follows:

webformobject.A ttributes.Add(" width", CStr(33) & "%")
Even though this is not complicated to do, I would like to know why these
objects do not have a direct property. Isn't one of the advantages of
using ASP.NET supposed to be having it generate the code/attributes for
us? If anyone knows a reason why the objects were designed this way, I
would like to know. Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

Nov 19 '05 #2
Greetings & Salutations,

You can also (for server controls & a few others) use the Width property as
well as the Unit class. Example:

Label1.Width = Unit.Percentage (55.3)
TableCell2.Heig ht = Unit.Pixel(50)

Gary K

"Nathan Sokalski" wrote:
I am sure most of us have enough experience with HTML to know that most HTML
elements allow you to specify the width and/or height attributes as
percentages. However, I have noticed that when setting properties for an
object on a webform (such as a TableCell) programmaticall y, the only way to
do this is by using the Add method of the Attribute property as follows:

webformobject.A ttributes.Add(" width", CStr(33) & "%")
Even though this is not complicated to do, I would like to know why these
objects do not have a direct property. Isn't one of the advantages of using
ASP.NET supposed to be having it generate the code/attributes for us? If
anyone knows a reason why the objects were designed this way, I would like
to know. Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

Nov 19 '05 #3

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

Similar topics

2
3169
by: Alex Shi | last post by:
In php, is there a way obtain the width of a charactor of a certain font? Alex -- ================================================== Cell Phone Batteries at 30-50%+ off retail prices! http://www.pocellular.com ==================================================
2
36394
by: Catherine Lynn Smith | last post by:
I want to use javascript to build page elements using onLoad but I seem to be having trouble defining the width value of an IMG tag if I create it with javascript. If I build the element with HTML it works just fine with: <img src="foo.gif" width="100%" height="100"> But if I try to create it within the javascript, it will not work.
14
21514
by: delerious | last post by:
I need to determine an element's width and height in pixels (not including padding, border, and margin) in Javascript. The element will not have width or height styles specified. In Mozilla, I know I can use document.defaultView.getComputedStyle() to do this. IE does not support document.defaultView.getComputedStyle(). It supports offsetWidth/offsetHeight, but those include the padding and border. IE also supports...
11
2919
by: Alec S. | last post by:
Hi, Is it possible to create a colored box like this? : <html> <head> <style type="text/css"> #bbb { background: #f00; position: absolute;
3
1670
by: Nathan Sokalski | last post by:
I need to get the width and height of a GIF image through code. I need this info so that I can set the width and height properties of Image and ImageButton objects. System.IO.File.GetAttributes(imagelocation) only seem to return properties that all files have, which does not include width and height. How can I get this info? Any help would be appreciated. Thanks. -- Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/
0
2384
by: Mike P | last post by:
Where exactly are the updateparameters of a gridview picked up from? I have created 2 very similar gridviews and given the updateparameters the same names as in my edititemtemplates. Yet this method has worked for 1 gridview and failed for the second gridview. Here is my gridview : <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:XConnectionString %>" SelectCommand="ViewForecast"...
18
18062
by: Erich Meier | last post by:
Hello there, is there any way to set the size of images or table cells in HTML not by pixels but by inches or in millimetres? The problem behind this is that you never know what kind of output device the consumers of your webcontent may use. For example they may use computer screens, but in different sizes and with different resolutions. That means, on one computer screen a single pixel has a different size than on another. Just...
7
9857
by: Christian Hackl | last post by:
Hi everyone, I've got a question about what makes the "img" element's width/height attributes valid HTML or XHTML. First of all, this is a rather theoretical question, but digging through the W3C HTML 4.01 standard and this group's archive didn't give me a satisfactory answer, so here we go: Is <img src="img.png" alt="" width="100px" height="100px"really valid?
2
3811
by: Jukka K. Korpela | last post by:
Sub titulo "Re: DIV borders different in IE7 when in td" scripsit Ben C: This seems to be the heart of the matter, and I'm trying to get a real discussion started, by moving the discussion to the right group (c.i.w.a.stylesheets) and changing the Subject line. It seems to me that IE 7, specifically in "standards mode" (!), misbehaves when a table cell has a declared width but the actual width
0
7969
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
8272
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
8381
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...
0
6688
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5847
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
5431
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();...
0
3886
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2404
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
1494
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.