Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the CSS in code behind asp.net

in my aspx page I have this div..

<div id="downloadableProducts" runat="server"><a href="#">Downloadedable Products</a></div>

I am trying to change the css in the code behind like this..

downloadableProducts.Style("display") = "none";

but this does not work, I get an error and red underline under downloadableProducts in the code behind and it says 'The name 'downloadableProducts' does not exist in the current context '

What am I doing wrong?

like image 644
user979331 Avatar asked Jun 04 '12 19:06

user979331


1 Answers

You need to add runat="server" to the div and access it as a HtmlControl in your codebehind. For example:

HtmlControl div1 = (HtmlControl)Page.FindControl("downloadableProducts");
like image 111
TheBoyan Avatar answered Nov 02 '22 17:11

TheBoyan