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.
Is the textbox directly on the page? Also what type of project is that? Is it a web application or web site opened from file system? If it's a Web Application, the designer may have failed to update YourPage.aspx.designer.cs file. Check that file to make sure you have a definition for txtName something like:
protected global::System.Web.UI.WebControls.TextBox txtName;
If its not there, delete .design.cs file, right click on the page and choose "Convert To Web Application. This will recreate .design.cs file correctly.