Asp.net controls are not accessible in code behind

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

    Make sure your control should have a generated code-behind reference at all! For example, if it’s in a list template then you’ll need to look up a reference to it in an item binding event handler.

    This drove me wild because I had two controls with the same ID, one was at page level whereas the other was in a template.

    I thought the generated reference I was using was for the one in the template and I couldn’t work out why a newly added control in the template wasn’t resulting in a generated reference.

    0 讨论(0)
  • 2020-12-15 17:28

    Problem is you might have multiple aspx files with codefile in page directive points to same codebehind file. It expects the same control to exists in all the aspx file linked to same code behind and thus throwing compilation error.

    If you still having the issue cleaning up the same as mentioned above, check the designer page and regenerate one.

    0 讨论(0)
提交回复
热议问题