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.
I had the same problem when I changed my asp.net website from 3.5 to 4.0.
To solve the problem I recreated the entire website in 4.0 page by page, making sure all pages have the same names.
I copied page contents for each page leaving out the top line that starts with <%@
from the 3.5 website to the 4.0 website.
I copied all the code in the page class in the code behind for for each page from the 3.5 to the 4.0 website.