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.