How Access A Server-Side div In Code Behind (Inside Content Page)

SilverLight picture SilverLight · Nov 25, 2012 · Viewed 15.4k times · Source

How to access a server-side div in code behind (inside content page)?
mean there is a div in content page like below:

<div id="MyDiv" runat="server">
</div>

but the code below does not work:

 MyDiv.Style.Add("display", "none"); 

EDIT
I am so sorry and that was my mistake!
The codes upper are correct and work perfect and there is no problem about them. My mistake was about my css and after fixing it every thing was ok.
so really thanks for attention and answers.

Answer

Amir picture Amir · Nov 25, 2012

to access element from content page you can use below code:

HtmlGenericControl myDiv = (HtmlGenericControl)MyDiv;
myDiv.Style.Add("Display", "none");