Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Build Your Own ASP.NET 2.0 Web Site Using CSharp And VB (2006) [eng].pdf
Скачиваний:
77
Добавлен:
16.08.2013
Размер:
15.69 Mб
Скачать

Meeting the Features

If you chose C# as your preferred language when you started the project, then you’ll see a slightly different code-behind file—something like the one pictured in Figure 5.9.

As you can see, the C# version contains a number of namespace references. But, for the VB template, Visual Web Developer adds these references to the Web.config file, thereby applying them to the whole project. This explains why a Web.config file is created for those who choose VB, but not for those using C#. In the end, the functionality is very similar, but the Visual Web Developer designers chose to implement this functionality differently for each language. Of course, it’s possible to add the namespace references to Web.config yourself if you’re using C#.

The – icons to the left of certain sections of your file (such as the starting points of classes and methods) allow you to collapse those sections, which can help you to manage larger code files. In Figure 5.10, I’ve collapsed the section of Default.aspx.cs that contains the namespace references—you can see that the using statements have been collapsed into a single ellipsis. If you hover your cursor over the ellipsis, you’ll see a preview of the hidden text.

Figure 5.10. Playing around with Visual Web Developer

IntelliSense

IntelliSense is a fantastic code autocompletion feature that Microsoft has included in the Visual Studio line for some time. In its latest incarnation as part of Visual

Web Developer 2005 Express Edition, IntelliSense is pretty close to perfection. This feature alone makes it more worthwhile to use Visual Web Developer than simpler code editors.

153

Chapter 5: Building Web Applications

Let’s do a quick test. If you’re using VB, delete a character from the end of the

Inherits System.Web.UI.Page line in Default.aspx.vb. As Figure 5.11 shows, IntelliSense will automatically display other words that could be used in that position.

Figure 5.11. IntelliSense displaying possible word autocompletions

IntelliSense behaves slightly differently depending on the language you’ve chosen to use. For example, if you’re using C#, IntelliSense isn’t triggered as frequently as it is for those using VB. You can activate IntelliSense yourself by pressing Ctrl-Space. Then, once you’ve selected the correct entry, press Tab or Enter to have the word completed for you.

The Toolbox

While editing a web form, web user control, or master page visually, the Toolbox will come in very handy. The Toolbox contains most of the popular ASP.NET controls, which you can drag directly from the toolbox and drop into your form. You must be viewing a form in the Web Forms Designer to see the proper controls in the Toolbox. If you can’t see the toolbox, which is shown in Figure 5.12, select View > Toolbox to make it appear.

Let’s give it a test-drive: double-click on the TextBox entry, or drag it from the

Toolbox to the form, to have a TextBox control added to your form.

The controls listed in the Toolbox are grouped within tabs that can be expanded and collapsed. In the Standard tab of the Toolbox, you’ll find the standard web

154

Meeting the Features

Figure 5.12. The Toolbox

server controls we discussed in Chapter 4. In the other tabs, you’ll find other controls, including the validation controls we’ll discuss in Chapter 6, which can be found in the Validation tab. Figure 5.13 shows the toolbox with all its tabs in the collapsed state.

Figure 5.13. The collapsed Toolbox tabs

The Properties Window

When you select a control in the web forms designer, its properties are displayed automatically in the Properties window. For example, if you select the TextBox control we added to the form earlier, the properties of that TextBox will display in the Properties window. If it’s not visible, you can make it appear by selecting

View > Properties Window.

The Properties window doesn’t just allow you to see the properties—it also lets you set them. Many properties—such as the colors that can be chosen from a palette—can be set visually, but in other cases, complex dialogs are available to

155