15.02.2015 Views

C# 4 and .NET 4

Create successful ePaper yourself

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

asP.neT Web forms ❘ 1153<br />

figure 40-2<br />

Note that the ASP.<strong>NET</strong> Web Site template is not used here in order to keep things<br />

simple for the fi rst example. The ASP.<strong>NET</strong> Web Site template includes techniques such<br />

as Master Pages, which you won ’ t examine until the next chapter.<br />

After a few moments, Visual Studio .<strong>NET</strong> should have set up the following:<br />

➤<br />

➤<br />

PCSWebSite1 , a new solution containing the <strong>C#</strong> web site PCSWebSite1<br />

Web.config , a confi guration fi le for the web application<br />

Next you need to add a web page. You can do this through the Website ➪ Add<br />

New Item . . . menu option. Select the Web Form template <strong>and</strong> leave the rest of<br />

the settings unchanged (with a file name of Default.aspx <strong>and</strong> the “ Place code<br />

in separate file ” option selected), <strong>and</strong> then click Add. This adds the following:<br />

➤<br />

➤<br />

Default.aspx , the fi rst ASP.<strong>NET</strong> page in the web application<br />

Default.aspx.cs , a “ code - behind ” class fi le for Default.aspx<br />

You can see all this in the Solution Explorer, as shown in Figure 40 - 3.<br />

You can view .aspx fi les in design or source (HTML) view. This is the<br />

figure 40-3<br />

same as for Windows Forms (as discussed in Chapter 39, “ Windows<br />

Forms ”). The initial view in Visual Studio is either the design or source view for Default.aspx (you can<br />

toggle between the views or view them together in a split view using the buttons in the bottom left). The<br />

design view is shown in Figure 40 - 4.<br />

figure 40-4<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!