Missing asp.net designer files

While working in Visual Studio on an ASP.Net web application (that was converted from a web site project), and which has controls defined in markup in a .aspx or .ascx file, you may find that attempting to reference the controls from the code-behind file causes an error such as:

‘[Type]’ does not contain a definition for ‘[indentifier]’  and no extension method ‘[indentifier]‘ accepting a first argument of type ‘[Type]’ could be found (are you missing a using directive or an assembly reference?)

This issue results from the fact that controls created on a .aspx or .ascx page within a website project do not have a .designer file.

A potential fix is to right-click on an individual file and choose ‘Convert To Web Application’. This forces Visual Studio to create the designer partial class file. Once the .designer file is created, the controls added in the markup of the .aspx or.ascx file become visible and accessible in the code-behind file as well, with intelliSense.

Advertisements