'txtName' is not declared. It may be inaccessible due to its protection level

后端 未结 13 1619
暖寄归人
暖寄归人 2020-12-15 19:22

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.

13条回答
  •  感动是毒
    2020-12-15 20:01

    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.

提交回复
热议问题