In this part of the walkthrough, you will learn how to work in Design view, which provides a WYSIWYG-like view of the page. You can add text by typing, as you would in a word processing program. You can format text directly with formatting commands or by creating in-line styles.
Design view displays your page in a way that is similar to how it will appear in a browser, with some differences. The first difference is that in Design view, the text and elements are editable. The second difference is that to help you edit your pages, Design view displays some elements and controls that will not appear in the browser. Additionally, some elements, such as HTML tables, have a special Design view rendering that adds additional space for the editor. Overall, Design view helps you visualize your page, but it is not an exact representation of how the page will render in a browser.
To add and format static HTML in Design view
-
If you are not in Design view, click Design, which is located at the lower left of the window.
-
At the top of the page, type ASP.NET Web Page.
-
Highlight the text to format to select it, and then on the Format toolbar, in the left-most list, click Heading 1.
-
Position the insertion pointer below ASP.NET Web Page, and then type This page is powered by ASP.NET.
-
Right-click This page is powered by ASP.NET., and then click Style.
The Style Builder dialog box appears.
-
Click Font, and then in Family, click the ellipsis (…) button.
The Font Picker dialog box appears.
-
Under Installed fonts, click Verdana, and then click the add (>>) button.
-
Click OK to close the Font Picker dialog box.
-
Click Text, and then in the Horizontal list, click Centered.
-
Click OK.
Viewing Tag Information
When you are working in Design view, you might find it useful to see the design surface tags, such as div and span, and others that do not have a visual rendering.
To see HTML design surface tags in Design view
-
On the View menu, click Details.
The designer displays symbols for paragraphs, line breaks, and other tags that do not render text.
Adding Controls and Elements
In Design view, you can drag controls from the Toolbox onto the page. You can add some elements, such as HTML tables, using a dialog box. In this section, you will add some controls and a table so that you have elements to work with later in the walkthrough.
To add controls and a table
-
Position the insertion pointer to the right of the closing paragraph mark for This page is powered by ASP.NET., and then press ENTER.
-
From the Standard group in the Toolbox, drag a TextBox control onto the page.
Note |
|---|
| You can also add a control by double-clicking it. |
-
Drag a Button control onto the page.
The TextBox and Button controls are ASP.NET Web server controls, not HTML elements.
-
On the Layout menu, click Insert Table.
The Insert Table dialog box appears.
-
Click OK.
The Insert Table dialog box provides options for configuring the table that you are creating. However, for this walkthrough, you can use a default table layout.
Creating Hyperlinks
Design view provides builders and other tools to help you create HTML elements that require property settings.
To create a hyperlink
-
In the text This page is powered by ASP.NET., highlight ASP.NET to select it.
-
On the Format menu, click Convert to Hyperlink.
The Hyperlink dialog box appears.
-
In the URL box, type http://www.asp.net.
-
Click OK.
Setting Properties in the Properties Window
You can change the look and behavior of the elements on the page by setting values in Properties.
To set properties by using the Properties window
-
Click the Button control that you added in "Adding Controls and Elements," earlier in this walkthrough.
-
In Properties, set Text to Click Here, ForeColor to a different color, and Bold to true.
-
Place the insertion point in the ASP.NET hyperlink that you created in the preceding section.
Notice that in Properties, the HRef property for the a element is set to the URL that you provided for the hyperlink.
Testing the Page
You can see the results of your editing by viewing the page in the browser.
To start the page in the browser externally
-
Right-click the page, and then click View in Browser.
Visual Web Developer starts the Visual Web Developer Web server, which is a local Web server that you can use to test pages without using IIS.
Changing the Default View
By default, Visual Web Developer opens new pages in Source view.
To change the default page view to Design view
-
On the Tools menu, click Options
-
In the Options dialog box, click HTML Designer, and then under Start Pages in, click Design view.
Note |
|---|
| You can run pages in several ways. If you press CTRL+F5, Visual Web Developer performs the start action that is configured on the property page for Start Options. The default start option for CTRL+F5 is to run the current page; that is, the page that is currently active in Source or Design view. You can also run pages in the debugger. For more information, see Walkthrough: Debugging Web Pages in Visual Web Developer. |