Asp.net controls are not accessible in code behind

后端 未结 26 1226
慢半拍i
慢半拍i 2020-12-15 16:25

I have a project that was previously built by someone else. When I try to add a new control to the page, I can\'t access it in the code behind. When I try to access it there

26条回答
  •  难免孤独
    2020-12-15 17:08

    Add an empty .aspx.designer.cs file to your project

    To have visual studio autocreate declarations of .aspx page controls you can add an empty YourWebPageName.aspx.designer.cs -file to your project.

    If added to the project externally you can add it to your project by right clicking the project, selecting new item and include the new .cs file into your project.

    Then, as soon as you make a minor modification to your YourWebPageName page in the design editor Visual Studio will populate your empty .cs file with declarations.

提交回复
热议问题