Top ten tips in ASP.NET programming

xiaoxiao2021-03-06  47

In this document, we will discuss 10 techniques that programmers need to pay attention to using the ASP.NET development application. These techniques involve the use of default controls and form names to the StringBuilder class, which helps programming Personnel can adapt to the .NET environment as soon as possible.

1. When using Visual Studio .NET, do not use the default name except for direct or non-reference objects.

One of the benefits of .NET is that all source code and configuration files are plain text files that can be edited using any text editor such as NotePad or WordPad. If you don't want, we don't have to use Visual Studio .NET as an integrated development environment. But use Visual Studio .NET, we can see the file in the Windows File Manager, or browse the file from the text editor outside of the text editor outside the Visual Studio .NET.

It has many benefits as the integrated development environment using Visual Studio .NET, the most prominent benefits are greatly improved production efficiency. Using Visual Studio. NET, we can develop software faster in the case of paying smaller costs. As an integrated development environment, an IntelliSense is provided with automatic code completion, providing dynamic help, real-time prompts for syntax errors when entering methods or functions, and other functions that can improve production efficiency.

Like other complex tools, Visual Studio .NET will also make us a frustration in front of how to give up its role and master their "habits". Sometimes it is like a black box that is difficult to understand, generate a lot of files and many useless code.

A feature of Visual Studio .NET is, whether objects in classes, controls, or forms can provide a default name for new objects. For example, if we created a new ASP.NET Web Application, its default name will be WebApplication1. We can easily change the name of the application in the New Engineering dialog, but at the same time, it is only the name of the name space of the application and its virtual directory, the default name of the source code file is still Webform1.aspx. And WebForm1.aspx.cs (C # Project) or WebForm1.aspx.vb (VB.NET Project).

We can change the file names used by the ASPX and code in the scenario browser, but the name of the web page will still be WebForm1. If a button is generated on the web form, its default name will be button1. In fact, the names of all controls are constructed by the type and number of controls.

We can, should also modify all the forms and controls of the application into meaningful names. For smaller demo programs, the default name can also be competent, but if the application has many buttons and labels by multiple forms, each form, like frmstartup, frmdataentry, and fmreports The names such as Form1, Form2 and Form3 are easier to understand and maintain.

If the control on the form is referenced elsewhere in the code, it is more important to have a meaningful name. BTNOK, BTNCANCANCEL and BTNPRINT have made the people who look at the code easier to understand, and thus, more easily than the names of Button1, Button2, button3 more easily.

A good way to modify a name that appears in all files in an engineering is that in order in the Visual Studio .Net menu, select the Edit -> Discovery and Replace "->" Replace "command.

When you read the code written in two weeks, we often like these code for the first time, so there is a need to help us understand the name of its meaning.

2, even if you do not use Visual Studio .NET, use code support files to improve applications' performance in all ASP.NET Web projects such as web applications, web services, or web controls, Visual Studio .NET The code supports files. The code support file makes the project better organization, module, and more suitable for multiplayer development teams. In addition, it also brings improvement in performance.

The content of the code support file is compiled into a class in a combined file, typically a DLL file, sometimes it can be an Exe file. This file resides in the application's assembly cache, you can get it immediately when the application starts.

If the code is included in the