| Web Development with Visual Studio 2008 |
| Oct. 1, 2007 |
Better support for Cascading Style Sheets (CSS) will bring Visual Studio 2008 up-to-date with many of the capabilities provided in Expression Web, Microsoft's Web tool for graphic designers, making it easier for developers to control the look and feel of pages they create and to design for multiple browsers. Also, JavaScript improvements could ease debugging and development for Web developers using AJAX technology to create better Web user interfaces, and they make Visual Studio more attractive to Web developers who have opted for other tools or even no tools at all. Catching up with Expression Some new features in Visual Studio 2008 are already present in Expression Web. Although both Visual Studio and Expression can be used to build Web sites, Visual Studio is more developer-oriented and includes the full range of Microsoft's programming tools, while Expression is aimed at graphic artists and designers. Web developers use Cascading Style Sheets (CSS) to separate the appearance of a page from its content and to ensure that pages on a site have a consistent appearance. CSS information can control virtually every aspect of a page's appearance, including the font, size, color, and alignment of text, as well as the margins and layout of images. Although CSS information can be placed in the same HTML file that contains the content, it is more commonly placed in one or more separate files, making it easier for every page on a site to use the same styles by referencing a common CSS file and to change the overall look of the site by selecting a different CSS file based on the user preferences. Previous versions of Visual Studio supported CSS, as long as the CSS information was included in the HTML file, but didn't work well with sites that placed CSS information in separate files. Visual Studio 2005 typically kept formatting or style changes with the HTML file instead of the CSS file. This is particularly inconvenient when a developer and a designer are collaborating on a site and where the designer is using a different tool for authoring style sheets. Visual Studio 2008 provides better support for separate CSS files, while continuing to support CSS that is contained in an HTML file. Visual Studio 2008 also includes features that help developers better understand the sometimes-complex relationship between styles and therefore better understand why a certain element of the page appears the way it does. CSS styles can inherit, or "cascade," settings from another style, adding new formatting attributes or modifying some of a previous style's attributes. In addition, multiple styles can be assigned to the same element in a page. Although these capabilities give CSS flexibility and provide designers with a great deal of freedom, they can also make it difficult to understand why certain elements of a page appear the way they do. Visual Studio 2008 includes a new CSS Properties window that shows the CSS rules that are applied to the selected element, including the hierarchy of inherited styles and which attributes are overwriting attributes from other styles. (For an illustration of the CSS Properties window, see "CSS Properties in Visual Studio 2008".) In addition to better CSS support, Visual Studio 2008 makes it easier for a developer to simultaneously view a Web page and its underlying HTML. Previous versions allowed a developer to open two windows, one with the page rendered as it would display in Internet Explorer, and one with the source code HTML, but the new SplitView feature puts both views in a single window. In addition, the active selection is tracked in both views. For example, selecting a block of text or an image tag in the HTML pane highlights the corresponding element in the visual display, and vice versa. This makes it easier to move back and forth between the two views and to quickly locate the HTML that applies to a page element. Tools for JavaScript With Visual Studio 2008, Microsoft is bringing to JavaScript some of the developer productivity features that have been available to developers programming in C# and VB. The increasing popularity of Asynchronous JavaScript and XML (AJAX), a combination of Web technologies that can make browser applications more interactive and responsive without resorting to multimedia plug-ins such as Flash and Silverlight, has also increased the use of JavaScript, making support for JavaScript an important feature for many Web developers. Microsoft's ASP.NET Web server supports AJAX through the ASP.NET AJAX add-on. The enhanced JavaScript capabilities of Visual Studio 2008 make it a more attractive option for those developers who have until now opted for simpler development environments. Visual Studio 2008 now includes IntelliSense support for JavaScript. IntelliSense is a Visual Studio feature that allows a developer to type a portion of text, such as the name of a function or variable, and have the development environment automatically complete the name (a feature sometimes called statement completion). It not only saves time typing code, but it acts as a kind of in-line documentation by providing a pop-up display showing what a function does and what parameters it takes. Visual Studio 2008 provides JavaScript developers with the full complement of IntelliSense features. Adding IntelliSense to JavaScript is particularly difficult, primarily because, unlike languages such as C#, JavaScript is a loosely typed language—developers are not required to formally specify the type of information stored in a JavaScript variable. In fact, the type of information held by a variable can change as a script runs. Although this provides programmers with a great deal of flexibility, it forces tools like IntelliSense to infer the type of information being stored in a variable before it can present the developer with the right set of options for statement completion. In addition to IntelliSense, Visual Studio 2008 includes debugging improvements that could appeal to JavaScript developers. ASP.NET pages often include a mixture of server-side and client-side JavaScript. Although Visual Studio 2005 allowed developers to debug both types of JavaScript, setting up the debugging environment was complex. Visual Studio 2008 simplifies the process by allowing the developers to set breakpoints (instructions to the tool to halt the program at a specified point so the developer can examine its state) on either the client-side or the server-side JavaScript and to move back and forth between the two. Many AJAX libraries, including Microsoft's ASP.NET AJAX add-on, create and download JavaScript code to the browser while the application is running. Visual Studio 2008 now lets developers examine and debug such code. The combination of IntelliSense and Visual Studio's debugging features could make Visual Studio 2008 popular among Web developers, even those who have so far preferred to use third-party tools or even simple text editors. Resources For an overview of other new features in Visual Studio 2008, see "Visual Studio 2008: A First Look" on page 19 of the Aug. 2007 Update. The home page for Visual Studio 2008, including download information, is msdn2.microsoft.com/en-us/vstudio/aa700830.aspx. |