• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » C# » Application » How to Create a Web Forms in C#
Next →
← Prev

How to Create a Web Forms in C#

By Dinesh Thakur

Web Forms consist of a combination of HTML, code, and controls that execute on a Web server that i’s running Microsoft Internet Information Services (lIS). Web Forms display a UI by generating HTML that is sent to the browser, while the supporting code and controls that run the UI stay on the Web server. This split between client-side interface and server-side code is a crucial difference between Web Forms and traditional Web pages. While a traditional Web page requires all of the code to be sent to ahd be processed at the Browser, Web Forms need to send only the interface controls to the browser ,and the page processing is kept on the server. This UI/code split increases the range of supported browsers while increasing the security and functionality of the Web page.

Web Forms are commonly referred to as ASP.NET pages or ASPX pages. Web Forms have an .aspx extension and work as the containers for the text and controls that you want to display on the browser.

ASP.NET (.aspx) pages and Active Server Pages (ASP) can coexist on the same server.

The file extension determines whether ASP or ASP.NET processes it.

Web Forms are often comprised of two separate files: the .aspx file contains the UI for the Web Form, while the .aspx.vb or .aspx.cs file, which is called a code-behind page, contains the supporting code.

When you create a new project in Visual Studio .NET, a default Web Form named WebForm1.aspx is automatically included in the project .

 

To create a new ASP.NET Web Application-project and a default Web Form you have to follow the following steps:

 

1. In Visual Studio .NET, on the Start Page, click New Project.

2. In the New Project dialog box, click ASP.NET Web Application, type the project name in the Location field, and then click OK.

                                In the New Project dialog box, click ASP.NET Web Application, type the project name in the Location field, and then click OK.

Visual Studio.NET creates a new Web application and a default Web Form that is, name WebForml.aspx. If you are expanding an existing project, you can use Solution Explorer to quickly add additional Web Forms.

                                Visual Studio.NET creates a new Web application and a default Web Form that is, name WebForml.aspx.

3. Now add the Button control from the toolbox:

                               add the Button control from the toolbox

4. Now right click on the button control and select the properties.

                               Now right click on the button control and select the properties

5. Now change the text property of the button from “Button” to “Message” or whatever you like .

 

                               the text property of the button

This will change the caption of button control from “Button” to “Message”.

 

                              change the caption of button control

6. Double click on the button control and write the following code in the Button 1_Click event.

                              Button 1_Click event

7. After saving the project you must build the project.

8. Now right click on the web form and select ”View in Browser”.

                              View in Browser

9. The output will appear looks like following figure.

                              

10. Now click on the Message button. you will see the following result.

                              

The steps to add additional Web Forms to a Web Application project:

1.In the Solution Explorer window, right-click the project name, point to Add, and then click Add Web Form. The Add New Item – Project Name dialog box opens.

2. In the Add New Item – Project Name dialog box, change the name of the Web Form, . and then click Open.

A new Web Form will be created and added to the project.

You’ll also like:

  1. Type of Windows Forms controls
  2. How to Create a Windows Application in C#
  3. Understanding HTML Forms
  4. PHP Forms Processing with $ _GET and $ _POST Methods
  5. What is Web Server?
Next →
← Prev
Like/Subscribe us for latest updates     

About Dinesh Thakur
Dinesh ThakurDinesh Thakur holds an B.C.A, MCDBA, MCSD certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps.

Dinesh Thakur is a Freelance Writer who helps different clients from all over the globe. Dinesh has written over 500+ blogs, 30+ eBooks, and 10000+ Posts for all types of clients.


For any type of query or something that you think is missing, please feel free to Contact us.


Primary Sidebar

C# Tutorials

C# Tutorials

  • C# - .NET Languages Types
  • C# - Dot Net
  • C# - Dot Net Framework
  • C# - Inheritance Types
  • C# - Features
  • C# - CTS
  • C# - CLS
  • C# - CLR
  • C# - Console
  • C# - MSIL
  • C# - Base Class Library
  • C# - Web Forms Creation
  • C# - C# Vs C++
  • C# - Statements Types
  • C# - JIT
  • C# - CLI
  • C# - Controls Types
  • C# - String Types
  • C# - Execution Model

Other Links

  • C# - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2023. All Rights Reserved.