How to create a program in ASP.NET

code

Web applications are created by adding web forms to an application, placing controls in the forms, and responding to user interaction with the forms. To create a web application, you use the .NET visual studio. It is used to create various types of web applications, and web services provide access to data. ASP.NET is a compiled programming environment that uses the .NET platform to create an application.

Create an ASP.NET web application

  • Click the Start button, and the Start menu appears.
  • Click Programs, and then click Microsoft Visual Studio.NET.
  • A submenu appears. Click Visual Studio.NET.
  • After Visual Studio.NET opens, click a file, and the file menu appears. Move your mouse over the new one and click Project in the submenu.
  • The new project opens, and you select the Visual Basic project folder and template set.
  • Select the ASP.NET web application and type a name for the web application.
  • Set the location of the web application when naming the web application, and the new project will be created at a specific location in Visual Studio.NET.

Naming a form

  • An empty web form is created in a web project, and you can change the project name. By default, the web form is named WebForm1.aspx.
  • Right-click the form name in the Solution Explorer and choose Rename from the shortcut menu.
  • Clear the form name and enter a new name and name the form with the .aspx extension.
  • Press Enter and the web form name is changed.

Change a class with a web form

  • The web form class name and the web form name are the same.
  • Change the class name by double-clicking on the form in the design window, and the code will open.
  • Change the class name.
  • The class name in the @page directive of the web form is also changed. Change the name of the class in the @page directive.

Add a web form

  • A web application can contain many web forms, and there is a default form, and many forms can be added to it in one project.
  • Right-click the project name and move the mouse to add, and choose add web form from the add submenu.
  • Name the web form in the name text box.
  • Select open to create a new form.
  • The name of the class must be the same as the name of the web form.

Designing forms

Visual Studio .NET provides drag-and-drop controls, as well as placement of controls on a web form. Basically, Visual Studio .NET has two layouts: a grid layout and a flow layout. The layout is very important because the entire web form depends on the layout.

Grid layout

It uses the absolute position controls of web forms. Depending on the size of the form, the position of the control will never change. Grid layout is used when you know the size of the control.

Flow layout

It does not place controls on forms and is automatically detected on the screen. If a control is positioned, the next control is positioned based on the width and height of the previous control. Flow layout is used when you don’t know the size of a control.

Add controls

Controls are added to a form instead of using HTML tags in the form. The Toolbar is used in Visual Studio .NET to perform operations on a table instead of using HTML table tags.

Open the form

  • Click a label control in the toolbar options, and a label control is selected.
  • Click the desired control on the form toolbar and place it.
  • Right-click the label control, and then choose Properties from the menu.
  • You can customize controls in the properties menu by renaming the field or changing the color of the text on the form.
  • You can add many controls to a web form.
  • You can also add buttons to a web form.