Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET auto-generate aspx.designer.cs turn off?

As I'm working on a asp.net/c# project, I'm confronted with the foobar.aspx.designer.cs that auto generates it's content. eg, when I'm changing the code/designer, the designer.cs automatically updates it's content.

As I'm bit of a control-dude, I'd like to maintain the code myself. I'm not happy with the overkill of comments I don't need. Like:

    /// <summary>
    /// Form1 control.
    /// </summary>
    /// <remarks>
    /// Auto-generated field.
    /// To modify move field declaration from designer file to code-behind file.
    /// </remarks>
    protected global::System.Web.UI.HtmlControls.HtmlForm Form1;

While I'd like to see the following:

    protected global::System.Web.UI.HtmlControls.HtmlForm Form1;
    protected global::System.Web.UI.WebControls.Button Button3;
    etc, etc

(don't mind the naming, ofcourse I'd give it some distinguishing nameing)

How to fix this? I checked google on this one, but couldn't find an answer so quickly...

like image 290
Joris Avatar asked May 26 '10 21:05

Joris


People also ask

What is aspx designer cs?

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.

Can I delete designer CS files?

So there is no conflict with the Web Application model you are using. When you see those designer files, you can now have developers safely copy them into your main code behind . cs files and safely delete the designers if you like.


1 Answers

I am not sure if you can disable the automatic generation of this file. Nor if it would be good idea to do so... If you really want (need?) to interfere with it I would rather look for a way to change its behaviour/format. Unfortunately I cannot provide a solution/hint for this either. You might have to look in the field of "custom tools" (for code generation) though.

Why are you so unhappy with the format of the file? I almost never even look at it :) And according to Scott Guthrie the designer file has been introduced in VS 2005 as "a place where Visual Studio is allowed to write 'ugly' code": Tutorial 2: Code-Behind with VS 2005 Web Application Projects.

Edit: Maybe this article by Scott Hanselman could be of any help? T4 (Text Template Transformation Toolkit) Code Generation - Best Kept Visual Studio Secret.

like image 180
scherand Avatar answered Sep 29 '22 08:09

scherand