Click here to Skip to main content
15,846,009 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi! I'm new in ASP.NET and i have a little problem. I have a div on my content page and i want to edit this div dynamically , but i receive an error and i don't know why. I searched a lot on Google ,but i didn't found anything.Can someone help me to resolve this problem? Thanks in advance!
This is my code:

<div class="div"  runat="server" >/<div>
<!-- This is on my content page -->

div.Attributes.CssStyle.Add("bottom", "80px"); 
// This is my code 

And this is my error: The name 'div' does not exist in the current context
Gihan Liyanage 27-Aug-14 3:50am    
Did you copy pasted aspx file ?

1 solution

Give the runat =server and ID to your div like
<div class="something" ID="mydiv" runat="server">

then you can find your div at code behind using ID like

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


mydiv.Attributes.CssStyle.Add("bottom", "80px");
Share this answer
Alex Slusar 27-Aug-14 3:54am    
Thank you very much!
vangapally Naveen Kumar 27-Aug-14 3:55am    

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900