ASP.NET

Conclusion The Page Rendering Model

The System.Web.UI.Page class includes a collection of server-side controls. Everything that ever makes its way out to the client browser was somehow generated by a server-side control. Even literal text on the page was rendered using a LiteralControl. When the ASP.NET runtime compiles a page, it scans the ASPX file for any tag that says runat=server and adds a member variable representing that control to the page's control tree. Nothing escapes being packaged as a control-when ASP.NET finds literal text on the page, ASP.NET packages that as a literal control. When it comes time for the page to render, ASP.NET walks the control list and asks each control in the list to render itself.

Visual Studio 2005 includes a useful designer that lets you drag and drop controls onto a page. This development environment lets you feel as though you're developing normal applications for a single machine, even though the UI is represented as HTML over HTTP.

We'll take a look at writing a custom control in the next tutorial.

Tutorial 3 Quick Reference

How to switch between ASPX Source code mode and Designer mode

The Design and Source tabs appear near the bottom left-hand side of the editor window


How to add a server-side control to a page

  1. Show the toolbox if it's not already showing by selecting View | Toolbox from the main menu

  2. Click on the control from the toolbar

  3. Drag the control onto the page


How to change the properties of controls on a page

  1. Make sure the page editor is in Designer mode

  2. Highlight the control whose property you want to change

  3. Select the property to edit in the property window


How to turn tracing on

  1. In Source code editing mode, edit the Page directive to include the phrase trace=true

    OR

  2. Select the Document element from the combo box near the top of Properties window

  3. Edit the Trace property to be true


How to change the size of a server-side control

  1. Click on the control once to highlight it

  2. Click on one of the handles appearing on the border of the control. Hold the mouse button down and drag the mouse until the control is the correct size


How to add a handler for a control's default event

Double-click on the control for which you want to handle the event


How to add a handler for a control event (other than the default event)

  1. Press the events button (the lightning bolt) in the properties dialog box

  2. Choose the event you want to add

  3. Double-click in the right-hand pane immediately next to the property in the properties dialog to have Visual Studio invent a handler name for you

    OR

  4. Type a name for the handler

  5. Visual Studio will add a handler for you


How to change the layout characteristics of a page

  1. Select Layout from the main menu

  2. Choose from Absolute, Static, Relative, or more detailed options from the Auto Position Options dialog box