Downloadedabl...">

Changing CSS in code behind asp.net

on my aspx page i have this div.

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

I am trying to change css in code like this.

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

but it doesn’t work, I get an error message and a red underscore under downloadableProductsin the code behind, and it says: "The name" downloadableProducts "does not exist in the current context

What am I doing wrong?

+5
source share
1 answer

You need to add runat="server"to the div and access it as HtmlControlin your code. For instance:

HtmlControl div1 = (HtmlControl)Page.FindControl("downloadableProducts");
+13
source

All Articles