Workaround: Missing Declarations for Controls in Designer File

Workaround: Missing Declarations for Controls in Designer File

  • Comments 9

We have seen some customers report the issue that certain controls are not getting generated correctly in the designer file in Visual Studio 2010 RC for the ASP.Net Web Application Projects.

We are currently working on a fix for this issue for the final RTM release.


You can work-around this issue by declaring the missing controls in the code behind file for the ASPX page.


When you add a Button control with ID as “Button1” to the aspx page normally you should see the following code be generated in the designer file for this control.


  • Protected WithEvents Button1 As Global.System.Web.UI.WebControls.Button


  • protected global::System.Web.UI.WebControls.Button Button1;

If this code is not being generated in the designer file you can work around this by adding this same declaration in the code behind file of the ASPX page for the web application projects.

VB: (*.aspx.vb)


CS: (*.aspx.cs)



If you have older versions of the project with the correct designer file you can work around this problem by simply cutting and pasting the missing controls from the older designer file to the code-behind file.

With this work around you will need to manually maintain these declarations when trying to rename/remove/add controls.


Leave a Comment
  • Please add 1 and 5 and type the answer here:
  • Post
  • This generally happen when you debugging application and change aspx markup mainly for server control, the designer file is not auto generated.

    Best approach is finish debugging first and make changes at aspx markup. If you had already done changes before debug stop, remove all changes and re do.  

    During debug you can able to make change at code behind but you could able to aspx markup

  • I would put the missing declaration in the designer file instead of the code behind file. The problem is that the designer file is not being updated correctly.

    Then you don't have to remove them again from your code behind file, once the automatic generation of the designer file starts working again.

  • This is happening in VS2008 as well. It happens when you copy a control from one page to another and not always happen...

  • We have a problem that the designer.cs file does not include declarations for objects that do not derive from Control but has the ID property. It worked fine in Beta2. Is this also because of the bug mentioned here or is it by design?

    For example:



     <my:TextField ID="FieldText" />



  • I think that it is unbelievable that you are looking to fix this bug in the RTM release and not looking to fix it with a patch to the RC. Effectively, you are stopping any real testing of Web Application Project development within VS2010 until RTM and then I suppose we will have to wait until SP1 for fixes to other bugs that were not found during the RC because it was unusable.

    This is very reminiscent of bugs I reported with the Windows Forms designer during the Betas and RCs of VS2005, only to be told that all focus was on Web development and Windows Forms would have to wait. What is it this time? MVC? XAML? Other?

  • We have a fix for this issue now and we are in the process of creating a patch. I believe we would be able to announce the patch publicly by end of the week.

    Sorry for the delay and inconvenience.


  • A Patch to fix this problem would be nice as soon as... VS2010 RC corrups the designer file every time you change the .aspx - Painful!!!

  • Today is Friday, is this patch going to be released today as you indicated?

  • The patch is now available at:

Page 1 of 1 (9 items)