ASP — ASP.NET Web Forms
Web Forms Page
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" %>
<html>
<body>
<form runat="server">
<asp:TextBox ID="txtName" runat="server" />
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
<asp:Label ID="lblResult" runat="server" />
</form>
</body>
</html>
Code Behind
public partial class Default : System.Web.UI.Page
{
protected void btnSubmit_Click(object sender, EventArgs e)
{
lblResult.Text = "Hello, " + txtName.Text;
}
}
Server Controls
| Control | Description |
|---|---|
| TextBox | Text input |
| Button | Click button |
| Label | Display text |
| DropDownList | Dropdown |
| GridView | Data display |
| Repeater | Repeat items |
ViewState
// Store in ViewState
ViewState["counter"] = 0;
// Retrieve from ViewState
int counter = (int)ViewState["counter"];
Mini Practice
- Create Web Forms page
- Add server controls
- Handle events
- Use ViewState
Up Next
Continue with ASP.NET Razor — Razor pages.
Related Topics
Frequently Asked Questions about ASP.NET Web Forms
What is ASP.NET Web Forms in ASP?
ASP.NET Web Forms is a fundamental concept in ASP. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn ASP.NET Web Forms?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn ASP.NET Web Forms.
Why is ASP.NET Web Forms important in ASP?
ASP.NET Web Forms is essential for ASP development. Understanding this concept will help you write better code and solve real-world problems more effectively.