Click here to Skip to main content
15,913,587 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
Posted
Comments
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
XML
<div class="something" ID="mydiv" runat="server">
//somecode
<div>



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

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

OR

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

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