Jul
3
Written by:
Javier Callico
7/3/2008
When you try to compile in .Net 2.0 (and up) web pages created using .NET 1.1 and automatically migrated by Visual Studio you may receive an error like this:
The name "SampleControl" does not exist in the current context.
If you try to declare the control in your code-behind file you will receive the following error:
The type "SamplePage" already contains a definition for "SampleControl".
The solution is very simple - but hard to find - and involves making the Page class partial and moving all control declarations to a .designer file.
This can be done automatically with the following steps:
1- Right click on the .aspx file for the codebehind file that doesn't compile.
2- Choose the 'Convert to Web Application' option.
This will create a .designer file, and the page will compile.
Tags:
2 comment(s) so far...
Re: About the error: The name ... does not exist in the current context
Thank you so much!!! I've been searching for this and could not find an answer anywhere!
By David on
3/16/2009
|
Re: About the error: The name ... does not exist in the current context
My God. I've been ripping my hair out over this stupid problem for at least an hour. Thank you for taking the time to document the fix for the rest of us!
By random anon webdev on
11/4/2009
|