0

I am not able to see auto-generated code in asp.net as we can see this code in win forms with designer.cs file.

partial class Form1
{
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.IContainer components = null;

    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }

    #region Windows Form Designer generated code

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
        this.components = new System.ComponentModel.Container();
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.Text = "Form1";
    }

    #endregion
}
4

1 回答 1

0

If you're using an ASP.NET "Web Site", then there is no auto-generated code. The markup is parsed and compiled without using a designer file.

In a "Web Application", you do get auto-generated designer files to go along with your regular code-behind file. It's in a partial class, so you actually have three physical files per page (.aspx, aspx.cs, .aspx.designer.cs).

These two concepts are very different from each other, so if you're unclear on the differences, I'd suggest doing a web search on asp.net website vs web application and reading about some of the other more important differences.

Although the WebSite does have advantages, most people tend to find a Web Application to be the preferred of the two - it's a more "real" .NET project. Also, ASP.NET MVC, which is continuing to grow over WebForms, is only available in a "Web Application", not a "WebSite".

于 2013-09-09T20:08:05.453 回答