General:
I need to dynamically change the class of a DIV element on pageload. I
have not been able to find any resources describing how to access the
page DOM from code behind. Can someone point me to a resources.
Specific:
I have web user control with a property that controls the class applied
to a DIV element. On page load I need to find the element by ID and
change the class.
Thanks,
BP
Scott Allen - 17 Jan 2006 02:27 GMT
What you can do is give the div runat="server" and id="<a name>"
attributes. ASP.NET will then wire up an HtmlGenericControl for you in
the code-behind file, and you can modify properties like Style, etc,
from code-behind.
--
Scott
http://www.OdeToCode.com/blogs/scott/
>General:
>I need to dynamically change the class of a DIV element on pageload. I
[quoted text clipped - 8 lines]
>Thanks,
>BP
hob - 23 Jun 2007 21:39 GMT
Hello,
How can I change (set) css class on div from external style sheet using code behind?
Thank you,
Hob
From http://www.developmentnow.com/g/8_2006_1_0_0_658580/Accessing-DOM-from-codebehind.ht
hob - 23 Jun 2007 22:07 GMT
I have to answer myself, but I wasn't looking for answer long, and I want to share it with others. The solution is simple - follow Scott's replay and when you want to set class you simple add in code behind something like x.Attributes.Add("class", "hidden"); where HtmlGenericControl x. Hope this is correct.
From http://www.developmentnow.com/groups/viewthread.aspx?newsgroupid=8&threadid=65858