Showing posts with label Visual Studio 2008. Show all posts
Showing posts with label Visual Studio 2008. Show all posts

Tuesday, May 29, 2012

Asp.Net designer file not updating (VS.Net 2008)

Problem
In Visual Studio 2008, i came across a strange error (The name 'xxxxx' does not exist in the current context), any additions/changes done to the control names in the .aspx/.ascx files were not getting updated to the designer.cs file as a result the following error was thrown while building the project

The name 'xxxxx' does not exist in the current context
D:\\Source Code\Programming\ucSysInfo.ascx.cs 226 53

This was because there was a mismatch between the names of the controls name in the .ascx and the .ascx.cs.designer files, ideally the designer file should get updated once the name is changed in the .aspx/.ascx files, but at times this is not happening leading to the issue. 

Solution
The following workaround helped me overcome this issue

1. Close the .aspx/ascx files and the .cs files, if it is opened in the Editor
2. Delete the designer file corresponding to the .aspx/.ascx file (in my case it was ucSysInfo.ascx.cs.designer)
3. Right click on the .aspx/.ascx file in the Solution Explorer
4. Select the option Convert to Web Application.
5. That's it the designer file will now get recreated with the new/updated control names.

The Project should now BUILD without any errors.