How a dynamic web page really works
Before you learn any control or any method, you need one clear picture in your head: what actually happens when someone opens a page that was built with server side code.
A static page compared with a dynamic one
A static page is a file. The server hands the same bytes to everyone who asks for it. A dynamic page is a program. The server runs that program, which builds the page from scratch, and then sends the result. Two visitors can receive two different pages from the same address.
The round trip, step by step
- The browser asks the server for a page by its address.
- The server finds the program that matches that address.
- The program runs, reads data, and writes the finished markup.
- The server sends that markup back to the browser.
- The browser draws it. If the markup included a form, the next submission starts the trip again.
// the server runs this, not the browser
protected void Page_Load(object sender, EventArgs e)
{
greeting.Text = "Hello from the server";
}Why this matters
Once you see a page as a program that runs on the server, the rest of ASP.NET stops being mysterious. Controls are objects the program can change. Events are messages the program receives. A database is just another source the program reads while it builds the page.
From here, the natural next step is to learn the language the program is written in, then to meet the server controls that do the common work for you.