After putting a textbox on my page when I compile it I get the above error:
\'txtName\' is not declared. It may be inaccessible due to its protection level.
This is what happened at my case.
-I have declared the variable at behind code
Protected Friend sMessage As String = ""
-Then the aspx : <%=sMessage%>
this case appears (visual studio 2015 - asp webform project)
Then I try to :
-clean solution
-Rebuild
Then the problem is gone
If the clean solution and rebuild does not work
try to clean the obj directory
If the variable is asp component
make sure runat="server" at the aspx file