div and HtmlGenericControl

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?
 
A

Anthony Jones

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")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top