a blog for those who code

Wednesday, 23 July 2014

Asp.Net : How to regenerate .designer.cs file for aspx or ascx files

If by any chance you have deleted your .designer.cs and you wanted to regenerate it or you wanted to update the .designer.cs file when you put new controls on your page. In this post we will show you how to force the Visual Studio to regenerate your .designer.cs file.

Before trying any solution just try to remove all the error from your aspx or ascx file, as any error on the file will prevent the Visual Studio to create a designer file for you, and it might happen that none of the solution will work for you.

Solution 1 :

Right Click on you aspx or ascx file and select "Convert to Web Application". As soon as you do this a new .designer.cs file will be created for you with all the controls in it.

Solution 2 :

Delete your old .designer.cs file if you want to update and create a new empty file with the same name, after saving your aspx or ascx file again, the designer class will be regenerated. If you simply want to create it, create a new empty file with the same name, after saving your aspx or ascx file again, the designer class will be created for you.

Solution 3 :

In your aspx or ascx file change the CodeFile="" to CodeBehind="" and save the page. The designer file will be updated immediately. After the designer file gets updated, changed it back to CodeFile="".

Solution 4 :

Simply cut all the code of the aspx or ascx file, save it and again paste the original code, save it again. It will regenerate your .designer.cs file.

If nothing of the above solution works for you, please let me know.

Please Like and Share the Blog, if you find it interesting and helpful.

3 comments:

  1. You cannot convert a single file to a web application in VS2013 anymore, there is no right-click context menu with that option.

    If you use "convert to web application" from the project menu, all CodeFile pages will be converted to CodeBehind, which isn't necessarily what is desired.

    ReplyDelete
    Replies
    1. @larrybud - Have you tried deleting your .designer.cs file, as after saving your .aspx and .ascx file it will regenerate .designer.cs file for you.

      Delete
  2. Somehow non if this solutions work for me.
    In VS 2010 Ultimate I do not even have a button "Convert to Web Application" (not in the project menu and also not when right-clicking the ascx-file or the project).
    I have also manually created a matching *.designer.cs file, but it does not get updated... Very strange behavior.

    ReplyDelete

Contact Us

Name

Email *

Message *

Sponsers

Best Hosting Plans

CC License