C # similarities between a Form file and an HTML text file

Source: Internet
Author: User
C # Form file, such as form1.cs, contains two files: form1.designer. CS and form1.resx. If you double-click form1.cs in Solution Explorer, the GUI of the form is opened. Double-click form1.designer. CS to open the structure of the form. Code (Partial class form1), which defines the attributes and events of each control in the graphic interface using code. This is actually the operation code of Visual Studio on the form. It is better not to write code here, there is a system planning code for the form. Right-click the graphic interface and click "view code" to open form1.cs. This is actually a user's code operation on the form, which usually contains a form event, Program Generally, code is written here.

This structure is similar to HTML text files (for example, test.html files: form1.designer.csis equivalent to form1.cs, this JS Code is generally the Event code of the webpage element and the function to be called by the event. Here is an example of winform and Web User Logon: In winform, there is a user name and password text box and a login button on the form interface, the interface is as follows:

. CS files.Source codeAll of them are written here. Let's take a look at the code here.
. Resx resource file. Some resources are stored here and generally do not need to be viewed.
. Csproj C # project file. You can open this project directly with vs, which is automatically generated and does not need to be viewed.
. Csproj. user is a configuration file automatically generated, which records the project generation path, project Startup Program, and other information. You do not need to check it.
. Designer. CS design file, automatically generated, not required.
. Aspx is a webpage file, where HTML code is written.

Designer. CS is a code file generated by the Form Designer. It initializes controls on the form (in the initializecomponent () function) previously, vs2003 put this part of code into the CS file of the form. Because this part of code does not need to be manually modified, vs2005 will separate it to form a designer. the CS file corresponds to the form. In this way, the remaining code in the CS file is code that is highly relevant to program functions for maintenance.

The following is an introduction to the *. Designer. CS file written by the http://hi.baidu.com/luyuanevil.

Since the definition statements of the control on the partial class page are moved *. designer. in the CS file, the so-called "no worries", Microsoft simply makes good people to the end, and all the control definition code is automatically generated. And a warning is given:

//------------------------------------------------------------------------------
// <Auto-generated>
// This code is generated by the tool.
// Running database version: 2.0.50727.1433
//
// Changes to this file may lead to incorrect behavior, and if
// Re-generate the Code. These changes will be lost.
// </Auto-generated>
//------------------------------------------------------------------------------

Now the problem arises. If the names of controls on the page are nonstandard or duplicate names occur, *. Designer. CS will not be automatically updated! Sometimes the system will not tell you which control has a problem, especially when the control is in the formview inserttemplate or updatetemplate! Therefore, it is strongly recommended that the control should be named in a standardized manner, and editmode can be attached when necessary. For example, the field userid: useridinserttextbox in inserttemplate, And the updatetemplate is useridupdatetextbox. Note that when the code on the entire page is compliant, the system can run "convert to Web application" to regenerate the corresponding designer. CS file! This function saves a lot of code for the construction of framebuilder3.0.

I still don't know which tool can complete this function. net should have such a tool, maybe in the form of a dynamic link library or *. does the EXE format exist? Examples and xsd.exe. If you want to know more, please kindly advise ~~

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.