Home  >  Article  >  Backend Development  >  About aspx.designer.cs

About aspx.designer.cs

巴扎黑
巴扎黑Original
2017-04-30 10:38:342648browse

Some instructions for .aspx files, .aspx.cs files and .aspx.designer.cs

.aspx file: (page) writes the page code. What is stored is the page design code. Just put the code of each control, and the processing code is usually placed in the .cs file.

.aspx.cs file: (code-behind page) to write class code. What is stored is program code. Generally stores queries related to database connections and databases. renew. Delete operations, as well as actions that occur after clicking each button, etc.

.aspx.designer.cs file: writes page design code. Usually, the configuration information of controls in some page controls is stored, which is the registration control page. This thing is a code file generated by the form designer, and its function is to initialize the controls on the form.

<%@ Page Language="C#" AutoEventWireup ="true" CodeBehind="Document .aspx.cs" Inherits="Admin10000.Web.Document" %>

CodeBehind is used to bind .aspx.cs files, and Inherits is used to bind .designer files.

How to regenerate designer.cs file

The server controls used in aspx pages will automatically generate declarations for the controls in aspx.designer.cs. Sometimes it will appear in the aspx page that a server control is clearly used, and the id and Runat attributes are added, but in the background It cannot be used in aspx.cs. In this case, you can check the declaration statement of this control in aspx.designer.cs and check whether the control type and id are consistent with those in aspx.

Before VS 2003, this part of the code was placed in the cs file of the form. Since this part of the code generally does not need to be modified manually, after VS 2005, it was separated to form a designer.cs file corresponding to the form. In this way, the remaining codes in the cs file are codes that are highly relevant to program functions, which is easier to maintain.

​If the designer.cs is wrong, or the file is deleted by mistake, you can regenerate it using the following method:

Delete the designer.cs file, then select the project, right-click and select "Convert to web application". A new synchronized desinger.cs will be automatically generated.

hint

There are two types of Web projects, one is WebSite that does not generate designer.cs, and the other is WebApplication that only generates this file.

Please refer to the difference between WebSite and WebApplication

The above is the detailed content of About aspx.designer.cs. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn