Datasheet

Notice how the <i> is closed before the <b> tag. Swapping the order of the closing tags leads to invalid
XHTML:
<b><i>This is some formatted text</b></i>
Always Add a DOCTYPE Declaration to Your Page
A DOCTYPE gives the browser information about the kind of HTML it can expect. By default, VWD adds
a
DOCTYPE for XHTML 1.0 Transitional to your page:
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
The DOCTYPE greatly influences the way browsers like Internet Explorer render the page. VWD’s default
DOCTYPE of XHTML 1.0 Transitional gives you a good mix between valid markup and pages that render
the same in all major browsers.
If you want to learn more about XHTML, get a copy of Beginning Web Programming with HTML,
XHTML, and CSS, ISBN: 978-0-7645-7078-0.
Besides HTML, an ASP.NET web page can contain other markup as well. Most pages will have one or
more ASP.NET Server Controls on the page to give it some added functionality. The next section briefly
looks at these ASP.NET Server Controls, and you get an in-depth look at them in Chapter 4.
A First Look at ASP.NET Markup
To some extent, the markup for ASP.NET Server Controls is similar to that of HTML. It also has the notion
of tags and attributes, using the same angle brackets and closing tags as HTML does. However, there are
also some differences.
For starters, most of the ASP.NET tags start with an
asp: prefix. For example, a button in ASP.NET looks
like this:
<asp:Button ID=”Button1” runat=”server” Text=”Button” />
Note how the tag is self-closed with the trailing slash (/) character, eliminating the need to type a sepa-
rate closing tag.
Another thing you may have noticed is that the tag and attribute names are not necessarily in all lower-
case. Because an ASP.NET Server Control lives on the server, it doesn’t have to adhere to the XHTML rules
used in the browser at the client. However, when a server control is asked to emit its HTML to a page that
is configured to output XHTML, it will do so in XHTML. So, the code for the same button looks like this
when rendered in the browser as XHTML:
<input type=”submit” name=”Button1” value=”Button” id=”Button1” />
Notice how the entire tag and its attributes conform to the XHTML standard.
Now that you understand the basics of an ASP.NET page and the HTML that it generates, it’s time to
look at VWD again. Knowing how to use the application and its many tools and windows is an impor-
tant step in building fun, good-looking, and functional web sites.
14
Chapter 1: Getting Started with ASP.NET 3.5
87593c01.qxd:WroxPro 1/25/08 9:05 AM Page 14