div and HtmlGenericControl

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

Hi

asp.net 3.5

I have this code:
HtmlGenericControl div =
(HtmlGenericControl)Page.FindControl("divCalendar");

I didn't find any better class to use than a HtmlGenericControl, but isn't
there a better class?

In addition I'm trying to rewrite a javascript over to c#:
if (div.style.display == "none") <<< javascript
Not sure how to convert that if test to c# as I don't find any display
property in the Style property of the HtmlGenericControl.

any suggestions?
 
Jeff said:
Hi

asp.net 3.5

I have this code:
HtmlGenericControl div =
(HtmlGenericControl)Page.FindControl("divCalendar");

I didn't find any better class to use than a HtmlGenericControl, but isn't
there a better class?

No. Its actually a very good match. In HTML terms DIV (and SPAN) are pretty
much generic themselves.
In addition I'm trying to rewrite a javascript over to c#:
if (div.style.display == "none") <<< javascript
Not sure how to convert that if test to c# as I don't find any display
property in the Style property of the HtmlGenericControl.

any suggestions?

the Style property has the type CssStyleCollection. Rather than exposing a
property for every possible style (which may vary depending on browser and
as new CSS standards are supported). It is special kind of name value pair
collection.

if (div["display"] == "none")

OR for standard known attribute names:-

if (div[HtmlTextWriterStyle.Display] == "none")
 
Back
Top