Working with Different Views of a Document


At the bottom of the designer window are tabs labeled Design, HTML, Code, and All. These tabs allow you to switch to different views of the same document. You re currently in Design view, which is a WYSIWYG view of the document. (Well, nearly WYSIWYG, anyway.)

Switch to HTML view by clicking the HTML tab in the designer window. No surprise: you ll see the HTML syntax for the document you re working with, as shown in Figure 4-4.

click to expand
Figure 4-4: Your page in HTML view.

While your page is in HTML view, you can see all the HTML elements, including <html> and <head>. Unlike working in Design view, where you can edit the body section only, you can edit a title or other header elements in HTML view. Obviously, HTML view is handy for when you prefer dealing with HTML directly. Any changes you make in HTML view are reflected back in Design view.

Notice that the text you typed (My First Web Forms Page) is in an HTML element either an <h1> element if you formatted it or a <p> element if you did not apply a format. By default, Web Matrix puts static text in <p> elements. The HTML is indented automatically. (For information about the formatting, see the sidebar Document Auto-Formatting later in this chapter.)

The names of the tags for elements you dragged from the Web Controls tab, such as <asp:Button> for the Button control, won t be familiar to you, because they re not standard HTML tags. I ll explain what ASP.NET does with these tags in the section Rendering Controls later in this chapter.

Switch to Code view by clicking the Code tab in the designer window. This tab shows only the code for the current document. Naturally, there is no code at the moment. When you add code to a page, the code is a part of the same file, stored above the opening <html> tag.

Finally, click the All tab to display the entire file with code, HTML, and all other content visible. There s no code in this page, but you can see a <script> element where the code would go.

start sidebar
Document Auto-Formatting

When you switch between Design view and HTML view, Web Matrix reformats your document automatically. The technical reason is that entirely different processes handle Design view and HTML view. Experienced HTML coders sometimes don t like the way the reformatting is done, preferring their own formatting. In this release, Web Matrix doesn t allow you to specify any preferences about how it formats the HTML in your document. If you really can t stand how Web Matrix formats your document, you can turn off Design view and work full time in All view. To set this mode, choose Tools, Preferences. In the Web Editing node, choose General and then select Preview Mode. I ll assume in this book that you re working in Design mode with Design view enabled. However, if you do choose to work in Preview mode, you can still perform every task described in the book. Now and then you ll just have to tweak the procedures.

end sidebar



Microsoft ASP. NET Web Matrix Starter Kit
Microsoft ASP.NET Web Matrix Starter Kit (Bpg-Other)
ISBN: 0735618569
EAN: 2147483647
Year: 2003
Pages: 169
Authors: Mike Pope
BUY ON AMAZON

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net