Asp.net controls are not accessible in code behind

后端 未结 26 1172
慢半拍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:11

    I solved this problem by forcing the VS to regenerate my designer file. For that :

    1. I deleted my designer.cs file.
    2. Copied the designer file of another page.
    3. Renamed the designer file and the partial class in it to match the name of my page code behind class.
    4. Deleted everything from the designer class body.
    5. Cut all the controls from the aspx markup page.
    6. Saved the aspx page.
    7. Pasted the controls back and saved the file again.

    This made VS recreate all the controls in the blank designer file.

    Hope that works for you.

提交回复
热议问题