03.11.2016 Views

Beginning ASP.NET 4.5 in CSharp and VB Opsylum

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

26 x CHAPTER 1 GETTING STARTED WITH <strong>ASP</strong>.<strong>NET</strong> <strong>4.5</strong><br />

from the ma<strong>in</strong> menu. This formats the document accord<strong>in</strong>g to the rules you have set <strong>in</strong> the Text<br />

Editor Options dialog box. Formatt<strong>in</strong>g is also available for a number of other document types,<br />

<strong>in</strong>clud<strong>in</strong>g C# <strong>and</strong> <strong>VB</strong>.<strong>NET</strong> code, <strong>and</strong> CSS <strong>and</strong> XML files.<br />

From now on, whenever you need a head<strong>in</strong>g <strong>in</strong> your document <strong>in</strong> Markup View, simply place<br />

the cursor <strong>in</strong> the Document W<strong>in</strong>dow where you want the head<strong>in</strong>g to appear <strong>and</strong> double-click the<br />

appropriate head<strong>in</strong>g <strong>in</strong> the Toolbox.<br />

NOTE This exercise serves as an example of add<strong>in</strong>g code to the Toolbox. For<br />

an element, you might prefer to type the code directly <strong>in</strong> the code editor.<br />

Alternatively, you could use a code snippet. Enter h1 <strong>in</strong> the editor <strong>and</strong> then press<br />

Tab. Visual Studio exp<strong>and</strong>s the code for the head<strong>in</strong>g to <strong>and</strong> positions<br />

your cursor between the two tags so you can start typ<strong>in</strong>g the head<strong>in</strong>g right away.<br />

How It Works<br />

Most of the steps <strong>in</strong> this Try It Out are self-explanatory. You started off by open<strong>in</strong>g a few w<strong>in</strong>dows that<br />

you frequently need when build<strong>in</strong>g websites. You then used the drag-<strong>and</strong>-drop features of the IDE to<br />

rearrange the w<strong>in</strong>dow layout accord<strong>in</strong>g to your personal preferences.<br />

You then added an HTML fragment to a custom tab <strong>in</strong> the Toolbox. When you drag any markup to the<br />

Toolbox, Visual Studio creates a Toolbox item for it that conta<strong>in</strong>s the selected markup. Whenever you<br />

need a copy of that markup <strong>in</strong> your page, simply double-click the item or drag it from the Toolbox <strong>in</strong>to<br />

Markup View. This is a great time saver for HTML fragments that you frequently use. You typically<br />

use this technique for larger blocks of code; for elements like the , Visual Studio has a better tool<br />

called Code Snippets, which you meet later <strong>in</strong> this book.<br />

At the end you used Visual Studio’s document formatt<strong>in</strong>g option to change the layout of the code <strong>in</strong> the<br />

document. This helps to keep the code organized <strong>and</strong> easier to read. You can fully change how the code<br />

is formatted by us<strong>in</strong>g the Options dialog box accessible through Tools Í Options. Then exp<strong>and</strong> the<br />

path Text Editor Í HTML Í Formatt<strong>in</strong>g, <strong>and</strong> click Tag Specific Options.<br />

Besides the w<strong>in</strong>dow layout <strong>and</strong> the Toolbox, Visual Studio enables you to customize a lot more <strong>in</strong><br />

the IDE. The follow<strong>in</strong>g section expla<strong>in</strong>s how to customize three other important IDE features: the<br />

Document W<strong>in</strong>dow, toolbars, <strong>and</strong> keyboard shortcuts.<br />

Customiz<strong>in</strong>g the Document W<strong>in</strong>dow<br />

Visual Studio gives you great flexibility with regard to how text is displayed <strong>in</strong> the Document<br />

W<strong>in</strong>dow. You can change th<strong>in</strong>gs like font size, font color, <strong>and</strong> even the background color of the<br />

text. You can access the Font <strong>and</strong> Colors sett<strong>in</strong>gs by choos<strong>in</strong>g Tools Í Options, <strong>and</strong> then choos<strong>in</strong>g<br />

Environment Í Fonts <strong>and</strong> Colors.<br />

One th<strong>in</strong>g I like to customize <strong>in</strong> the Document W<strong>in</strong>dow is the tab size, which controls the number of<br />

spaces that are <strong>in</strong>serted when <strong>in</strong>dent<strong>in</strong>g code. To change the tab size, choose Tools Í Options, <strong>and</strong><br />

then under Text Editor choose All Languages Í Tabs. I usually set the Tab <strong>and</strong> Indent Size

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!