To get to this dialog box, choose File ➪ Open Web Site in VS (don’t accidentally choose File ➪ Open Project because that menu item is used to open Web Application Projects instead). All the examples in the book assume that you always open the Planet Wrox website from the local filesystem, using the File System button, which is the first button in the left column of the window. Then in the right pane, locate your website (C:\BegASPNET\Site in this example) and click the Open button. The site you created in the previous Try It Out is a very bare-bones site. To make it more useful, you need to add files to it. The many file types you have at your disposal and the way they are added to the site are the next topics of discussion.
Working with Files in Your Website
An ASP.NET Web Forms Site consists of at least a single Web Form (a file with an .aspx extension), but usually it consists of a larger number of files. Many different file types are available in VS, each offering a distinct functionality. In the next section, you see the most important file types that are used in VS. In addition, you learn a few different ways to add these files to your site.
The Many File Types of an ASP .NET Website
To give you an idea of how many different files you can use in ASP.NET, Figure 2-6 shows the dialog box that enables you to add new files to the site (accessible by right-clicking your website in the Solution Explorer and choosing Add ➪ Add New Item or by choosing Website ➪ Add New Item from the main menu).
To make it easier to find the type of file you’re looking for, you can use the search box at the topright corner of the dialog box. Simply enter a few letters of the type you’re looking for and hit Enter. VS filters the list of files to those matching your search phrase. The files you can add to a site can be grouped in a few different categories. The most important files — the ones you use throughout the examples in this book — are discussed next.
Web Files in asp.net
How to: Add ASP.NET Web Forms Page to a Web Project
This
topic describes how to add new and existing Web Forms pages to a Web project. For
information about creating an ASP.NET Web project, see How to: Create File
System Web Site Projects or How to: Create New Web Application
Projects.
Note
|
This topic applies only to ASP.NET
Web Forms pages. It does not apply to pages that you create
using ASP.NET MVC (Model View Controller) or ASP.NET Web
Pages.
|
Web
site projects in Visual Studio are directory based. When you open a Web site
project, Visual Studio treats all of the files in the folder you open — whether
the files are in the file system, in an Internet Information Services (IIS)
application, or on an FTP site — as part of the same Web site. For Web
application projects, the project file (.csproj or .vbproj) determines whether
a file is included in the project or not. The procedures in this topic will
work for both project types.
For
information about the difference between Web site projects and Web application
projects, see Web Application Projects versus Web Site Projects in Visual
Studio.To add a new ASP.NET Web Forms page to a Web siteIn Solution
Explorer, right-click the project name, and then click Add New Item.In
the Add New Item dialog box, under Installed Templates, click
the language that you want to work with, and then click Web Form.
Note
|
You can include pages with different programming languages
in the same Web site project. For more information, see Walkthrough:
Code Editing in Web Forms Pages in Visual Studio.
|
If
you want the code for the page to be in a separate file, be sure that
the Place code in separate file check box is selected. If you want to
keep the code and markup in the same file, clear this check box.In
the Name box, type a name for the new Web page, and then
click Add.The new ASP.NET Web page is created and displayed in Visual Studio.
To
add an existing ASP.NET Web Forms page to a Web site project In Solution
Explorer, right-click the project name, and then click Add Existing Item. In
the Add Existing Item dialog box, navigate to the directory
containing the Web page that you want to add, select the page, and then
click Open. The ASP.NET Web page is added to the project.
Note
|
When you add an existing file to a
Web site, the file is copied to your project, not added by reference. Thus,
if you change the file in your project, the original file is left unchanged.
|
No comments:
Post a Comment
We are happy for leaving comments,we will don't let you bite stay with us