c# - ASP.Net get an error when trying to adjust css in code behind -


i have code in code behind:

if (request.querystring["category"] == "9") {     htmlcontrol downloadableproducts = (htmlcontrol)page.findcontrol("downloadableproducts");     downloadableproducts.style.add("display", "none"); } 

it generating following error:

system.nullreferenceexception: object reference not set instance of object. on line 43 downloadableproducts.style.add("display", "none");

my div looks this:

<div id="downloadableproducts" runat="server">     <a href="#">downloadedable products</a> </div> 

what doing wrong?

if remove line code behind:

htmlcontrol downloadableproducts = (htmlcontrol)page.findcontrol("downloadableproducts"); 

i error:

the name 'downloadableproducts' not exist in current context

since downloadableproducts runs @ server, should able remove line 42. commented out below:

if (request.querystring["category"] == "9") {     //htmlcontrol downloadableproducts  = htmlcontrol)page.findcontrol("downloadableproducts");     downloadableproducts.style.add("display", "none");  } 

this worked me...


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -