What is Web Matrix?
From first impressions, you may think that Web Matrix is just a simplified development environment for building ASP.NET applications. In fact, it provides much more than this. As well as ASP.NET pages (including mobile device pages), Web Matrix can be used to create user controls and class files (for compiling into assemblies), Web service files, and even HTTP Handlers. It also provides integrated support for creating and editing HTML pages, style sheets, XML schemas and documents, text files and SQL scripts, and .NET configuration files (such as web.config and global.asax). Web Matrix also provides powerful wizards that automate much of the process of creating pages that handle data, pages that use output caching, and pages that use the built-in ASP.NET authentication features. It also comes complete with its own web server, and other useful addins. You can even create and install your own add-ins if you wish. Why Use Web Matrix Instead of Visual Studio .NET? Before we look in detail at Web Matrix, it’s worth exploring the differences between it and Visual Studio .NET. After all, why should Microsoft provide two different development environments for ASP.NET? The answer is that they complement each other – they target different types of development. Visual Studio .NET is an excellent team development environment, which – when integrated with a source file control system such as Visual SourceSafe – provides for the safe and consistent management of project files when a team of people are working on a project. One big difference between Web Matrix and Visual Studio .NET is that the latter insists on creating ASP.NET projects using the code-behind technique, rather than inline code. Many traditional ASP developers are used to including the presentation content (such as HTML, text, etc.) in the same file as the ASP code that creates and manages the dynamic interface content. Whether this is a good idea depends on how you (and your team) actually develop applications. If you employ graphical designers to build the visual parts of pages, and then employ other, more technically oriented programmers to build the code, you may prefer to have separate files for these two sections of the interface. However, you might prefer to include both code and visual content in the same inline page, perhaps to avoid the added complexity of having to compile the code-behind file and then inherit from it in the visual interface page (even though Visual Studio .NET does this for you). Developing in this way, until Web Matrix appeared, meant going back to the pre-ASP.NET approach of using a simple text editor (such as Notepad) or some other third-party tool. In summary, the differences between Web Matrix and Visual Studio .NET are: ❑ Project-based Solutions – Visual Studio .NET has the concept of a project, to which you can add various types of file and resource. Web Matrix does not use a project-based approach; instead it treats each file as a separate item. ❑ ASP.NET Page Structure – Web Matrix creates ASP.NET pages using the inline approach, rather than the code-behind approach of Visual Studio .NET.
A Road Map to the Web Matrix IDE
The Web Matrix IDE is designed to provide a familiar interface for developers who have used Visual Studio .NET. It includes the usual menu bars and toolbars across the top, a Toolbox down the left, various « project windows » down the right, and a status bar across the bottom. The following screenshot shows the default layout for a new ASP.NET page: In the current release, the Toolbox and project windows are not moveable, though they can be resized, and the Toolbox can be hidden. The main work area is a multiple document interface (MDI), so you can open several files at the same time for editing. In the following sections, we’ll look in detail at each section of the IDE. Menus and Toolbars Many of the menu entries and icons on the toolbar are familiar items for any Windows user. The File menu contains commands to create, open, save, close, print, and preview files. The Edit menu contains commands that allow you to undo or re-do your recent edits, and to cut, copy, paste, and select text, as well as the usual Find and Replace options and a command to go to a specific line in the page. The Edit menu also contains commands to add code snippets (something we’ll look at when we examine the Toolbox in more detail) and commands to edit the currently selected element when in Design view, or to edit the templates for a DataList control. Again, we’ll see more about these features later on. The final group of commands on this menu allows you to format pages, and to comment or un-comment the currently selected text or controls in either HTML or Code view (both of which will be covered in more detail when we look at the edit window later on). The View menu can be used to select a specific view of the current page or file (depending on the type of file). In the earlier screenshot of the IDE itself, you can see tabs at the bottom of the main edit window, which correspond to the four views: Design, HTML, Code, and All (all of which are covered in more detail when we look at the edit window later on). The View menu also includes commands to start the current ASP.NET page running in your default browser, display or hide the Toolbox, toggle the view of glyphs (such as the form and /form items visible in the earlier screenshot of the Web Matrix IDE), show or hide the borders of elements, show or hide the editing grid, and specify if the snap-to-grid feature is on or off.