My current aspx.designer.cs is not working properly, does anybody have any idea about regenerating aspx.designer.cs in solution explorer.
-
1What do you mean by "is not working properly"? – kostas ch. Dec 31 '13 at 13:32
-
I was refactoring a very old WebForms and found that a) make sure on the file property select 'Compile' and b) select the .aspx and on the menu project, convert to Application. – fcm May 05 '20 at 20:03
1 Answers
Found here:
Update (based on comment from @Gone Coding):
Suggestion: Back up your [page-name].aspx.designer.cs file(s) before making any of the changes described below.
Within the Visual Studio:
1) Remove your aspx.designer.cs file 2) Right click on your aspx file and select "Convert to Web Application" or for VS2017 click on your aspx file and then from Project menu, click "Convert to Web Application"
This should add the aspx.designer.cs back and up to date.
If you get an error saying:
"Generation of designer file failed: The method or operation is not implemented."
Try close Visual Studio and then reopen your project and do step number two again
And here:
Missing or corrupted designer file causes Visual studio (VS) to fail the build. This is because without designer file VS is unable to find the declarations of controls. Also most of the time controls are not added to designer.cs giving build errors.
To fix this issue, Below is the simplest solution I know:
- Delete your designer file if it is corrupted else start from step2.
- Go to your aspx markup (source) page and find below line of code.
<%@ Page Language="C#" AutoEventWireup="false" CodeFile="SamplePage.aspx.cs" Inherits=" SamplePageClass" %>
- Now change CodeFile tag to CodeBehind.
- Save the file.
- Rebuild your project (This will create designer file for your page)
- Revert your change (Step3).
-
2I am using Visual Studio 2012 Express edition, when I Right click on aspx file the option "Convert To Web Application" is not available there. What should I do now? – Mohammad Shafi Shaikh Jan 01 '14 at 03:54
-
21**Step 1 Should read: Backup your `aspx.designer.cs` file first!** These instructions **DO NOT WORK** on more recent versions of Visual Studio. – iCollect.it Ltd Jun 13 '14 at 09:12
-
-
3
-
-
52Note that in Visual Studio 2015, this option is no longer in the right-click menu. It can be found in the main menu under Project -> Convert to Web Application when you have a .aspx file selected in solution explorer. – AaronSieb Nov 10 '16 at 22:07
-
AaronSieb's comment also works for VS Professional 2013 version 12.0.40629.00 Update 5 – Deepak Agrawal Sep 11 '18 at 15:03
-
5
-
2
-
@GoneCoding I added your suggestion to the answer - very good idea in my opinion. – qxotk Dec 03 '19 at 20:03
-
Thank you very much. I have moved old webform application to asp.net mix version. You can convert single file or complete folder to web application. – Ali Aug 25 '20 at 04:26
-
On Visual Studio 2019 Step 1 select the Example.aspx.designer.cs Step 2 Right click and select delete. Choose yes Step 3 The file has been deleted. Step 4 Now we regenerate the file. • Select the aspx file • On the Menu select Project and click Convert to Web Application • Click yes Step 5 The file is regenerated – Sydney_dev May 23 '21 at 20:43