James Ray Anderson

James Ray Anderson
James Ray Anderson
0 comments

Solving "the Name 'controlname' does not exist in the current context" problem

1:10 PM
This is actually an easy issue to rectify. Maybe this is your situation.

CodeFile SnafuYou have a web page that references a code-behind file that is being used by multiple web pages. I.E., you made a copy of the page as a backup but forgot to change the "CodeFile" attribute to point to the new page. Since Visual Studio automatically picks up the new files in the directory it becomes visible to the compiler. The problem occurs when add a new control to the page you are working on and then try to reference it in the code. You compile...and then you get the error.

SOLUTION: Exclude the copied page, fix the CodeFile of your backup, or add the same control to your backup page.

0 comments:

 
Toggle Footer
Top