Control Height

  • Thread starter Thread starter Eric
  • Start date Start date
E

Eric

Given
System.Web.UI.Control Control

Can I determine the height of Control without knowing specifically what it
is?
 
only client code can know this, unless the style sets an absolute size and
specifies an overflow behavior.

-- bruce (sqlwork.com)
 
Usually controls on the HTML do not have height. (unless was specified in
style).
It's totally up to browser how it renders it. And browser renders controls
based on the size of the window

So i am not sure what you asking for.

George.
 
Hi Eric,



Thanks for posting in the community!
From your description, you're wondering whether it possbile to set the
height attribute of a System.Web.UI.Control's instance without knowing what
the contro acutally is, yes?
If there is anything I misunderstood, please feel free to let me know.

As for this question, here is my suggestion:
1. The System.Web.UI.Control haven't any properties such as Style or event
Height,width to let user specify any of such attributes. In fact, this is a
generic base class of all other web controls. If you'd like to found the
most basic web control base class that has such properties, you may have a
look at the System.Web.UI.WebControls.WebControl class. And here is the
description in MSDN:
------------------------------
The WebControl class provides the properties, methods, and events that are
common to all Web server controls. You can control the appearance and
behavior of a Web server control by setting properties defined in this
class.
#Note Not all controls support every property defined in this class. For
specific information about whether a property is supported, see the
documentation for the specific control.
------------------------------
For more detailed description on the WebControl base class, you may view
the following reference in MSDN:
#WebControl Class
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwebuiwebcontro
lswebcontrolclasstopic.asp?frame=true


2. As George has mentioned, all the web server controls will be rendered as
Html elements in the client html page. So in fact, the Style properties
such as Heidht, Width... of the control will be mapped to the proper html
element's attribute. For example, a TextBox Server Control will be rendered
as a <input type=text ..> ,if we specify the "height" and "width" for it,
the two server side properties will be mapped the the below html element
attributes:
<input type=text style="height:30;width:40">
However, some other control will mapped the same property in different way,
such as <table> will mapped the height and width as <table width=..
height=...>
So, it's better to know what the control is when you'd like to specify some
style attributes of the WebServer Control. Do you think so?

And here are some further tech reference on dealing with Styles on ASP.NET
web server control:
#Styles in Server Controls
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconstylesinservercont
rols.asp?frame=true

#.NET Samples - ASP.NET Style Customization
http://msdn.microsoft.com/library/en-us/cpqstart/html/cpsmpnetsamples-aspnet
stylecustomization.asp?frame=true

#ASP.NET Server Controls and CSS Styles
http://msdn.microsoft.com/library/en-us/vbcon/html/vbconwebformscontrolscsss
tyles.asp?frame=true

Hope they're also helpful to you.



Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Steven,
Thanks for the reply. The problem is I don't know if the control I'm
checking will always be derived from WebControl, it might be UserControl and
I was trying to avoid having to check everytime but it looks as if I will
have to.

Thanks
 
Hi Eric,


Thanks for your followup. Yes, when runtime dynamically load a control and
no idea of its type, its better for use to first get its type and then do
certain operations depend on what kind of control it is. And this is very
important when we dealing with page which are composite of many dynamically
loaded control. Anyway, thanks again for posting here.




Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Back
Top