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.
The way the classes are ordered is that your page's generated class inherits from your codebehind class - they're not partials, and it's not the other way around. This means that your codebehind class has no knowledge of the controls you've placed on the page. If you want access to a property that you declare in the page itself you need to declare it in the codebehind class first:
protected TextBox txtName;
You can then access this member in the codebehind file. This will get wired up correctly to match your control in the page.