Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate aspx.designer.cs in visual studio? [duplicate]

My current aspx.designer.cs is not working properly, does anybody have any idea about regenerating aspx.designer.cs in solution explorer.

like image 317
Mohammad Shafi Shaikh Avatar asked Dec 31 '13 13:12

Mohammad Shafi Shaikh


People also ask

What is ASPX designer cs file?

aspx. designer. cs file contains all the definition of the controls that are being used by the page. It's just segregation of the code using partial class feature.


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:

  1. Delete your designer file if it is corrupted else start from step2.
  2. Go to your aspx markup (source) page and find below line of code. <%@ Page Language="C#" AutoEventWireup="false" CodeFile="SamplePage.aspx.cs" Inherits=" SamplePageClass" %>
  3. Now change CodeFile tag to CodeBehind.
  4. Save the file.
  5. Rebuild your project (This will create designer file for your page)
  6. Revert your change (Step3).
like image 164
Nagaraj S Avatar answered Oct 02 '22 03:10

Nagaraj S