Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Specifying Width and Height properties as percentages

Reply
Thread Tools

Specifying Width and Height properties as percentages

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      06-13-2005
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) programmatically, the only way to
do this is by using the Add method of the Attribute property as follows:

webformobject.Attributes.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
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.nathansokalski.com/


 
Reply With Quote
 
 
 
 
Lau Lei Cheong
Guest
Posts: n/a
 
      06-13-2005
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.Attribute.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" <(E-Mail Removed)> glsD:%(E-Mail Removed) .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) programmatically, the only way to
>do this is by using the Add method of the Attribute property as follows:
>
> webformobject.Attributes.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
> (E-Mail Removed)
> http://www.nathansokalski.com/
>
>



 
Reply With Quote
 
 
 
 
Gary K
Guest
Posts: n/a
 
      06-15-2005
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.Height = 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) programmatically, the only way to
> do this is by using the Add method of the Attribute property as follows:
>
> webformobject.Attributes.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
> (E-Mail Removed)
> http://www.nathansokalski.com/
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why can't I change height with <col width="50" height="100">? Bernd Meier HTML 6 01-14-2008 07:25 AM
Specifying Width and Height properties as percentages Nathan Sokalski ASP .Net Web Controls 2 06-15-2005 03:36 AM
Specifying Width and Height properties as percentages Nathan Sokalski ASP .Net 2 06-15-2005 03:36 AM
CSS min-width, max-width, and min-height with display:inline Lois HTML 1 12-27-2004 03:03 AM
createElement('img') and .width properties in percentages? Catherine Lynn Smith Javascript 2 10-06-2003 01:15 PM



Advertisments