When you think ASP, think...
Recent Articles xml
All Articles
ASP.NET Articles
Related Web Technologies
User Tips!
Coding Tips
spgif spgif

Book Reviews
Sample Chapters
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Stump the SQL Guru!
Web Hosts
Author an Article
spgif spgif

ASP ASP.NET ASP FAQs Feedback topnav-right
Print this Page!
Published: Saturday, March 27, 2004

Getting the Most Out of Visual Studio .NET

By Scott Mitchell

Tips for Visual Studio 2005...
The tips in this article focus on Visual Studio .NET 2002/2003. Of course, many of these tips and tricks will work in Visual Studio 2005, but this article was written more than a year before Visual Studio 2005 was officially released. You can keep abreast of Visual Studio 2005-specific articles in the Using Visual Studio section of the Recommended ASP.NET 2.0 Articles page.


If your job entails creating Web applications with ASP.NET, you likely use Visual Studio .NET (VS.NET) as your development environment. While Visual Studio .NET is a very powerful development environment, I've found many of its quirks to be annoying. For example, I loathe creating my ASP.NET Web pages in the GridLayout. Previously, everytime I created a new ASP.NET Web page the very first thing I'd do was right-click in the Designer and change the Page Layout option from GridLayout to FlowLayout. Recently, though, I discovered how this feature can be disabled permanently!

- continued -

In this article we'll discuss how to tweak Visual Studio .NET so that it's most productive for you. Visual Studio .NET is too large a beast for one man to know all of its intricate secrets, so if I am missing any options you find indespensable, or am lacking the hacks you have thrown together to make Visual Studio .NET work for you, please let me know, and I'll be sure to add your suggestions to this article!

One final word: the customizations I mention were tested with Visual Studio .NET 2003. If these customizations need further tweaking to work with VS.NET 2002, please be sure to let me know. Thanks!

Setting the Default Page Layout

The Page Layout property can be configured in the Project's Properties dialog box. As mentioned in the Introduction, one of my biggest peevs with Visual Studio .NET is that, by default, it has new ASP.NET Web pages created with the GridLayout. I prefer working in FlowLayout, and find it annoying that each time I create a new ASP.NET Web page I have to manually change the page layout from GridLayout to FlowLayout.

Thankfully, you can customize if ASP.NET Web pages should use GridLayout or FlowLayout by default for a given ASP.NET Web application project. Once you have opened an ASP.NET Web application Project, right-click on the Project name in the Solution Explorer and go to Properties. From the Properties dialog box, select the Designer Defaults option from the left. This will display, among other drop-down lists, a Page Layout drop-down list (see the screenshot on the right). You can specify here that the default page layout should be FlowLayout for the ASP.NET Web pages in this project.

Viewing ASP.NET Web Pages in the HTML View By Default

You can make the HTML view the default view from the Tools/Options menu. By default, whenever you create or load an ASP.NET Web page, it shows the page in the Design view. This is great if the first things you typically do is drag on Web controls from the Toolbox, but, if you're like me, you usually start working on a page by hand-entering HTML markup. If you fall into this camp, then you'll likely save a couple seconds by having ASP.NET Web pages open in HTML view by default.

To set the HTML view as the default view, go to the Tools menu and choose Options. From the list of Options on the left, choose the HTML Designer option. Then, on the right, you can choose to start Web Form pages in HTML View, as shown in the screenshot to the left.

Add Line Numbers to Your Code-Behind Classes

Did you know that you can add line numbers to your code files in VS.NET? Line numbers are especially helpful if discussing a block of code with someone else, as you can refer to a specific line numbers. To turn on line numbers, go to the Tools menu, choose Options, and from the left-hand side select the Text Editor / C# or the Text Editor / Basic options. In the right-hand side you'll find a "Line numbers" checkbox. Check this and line numbers will be added to your code files, as shown below.

You can add line numbers to your code files.

Creating Custom Web Form Wizards

When working with an ASP.NET Web application you can add new files to the project by right-clicking on the project name in the Solution Explorer, choosing Add, and clicking on Add New Item. This pops up a dialog box from which you can choose a file type to add, such as a Web Form, an XML file, a Web User Control, a Web Service, and so on. Did you know that you can create your own "types" here by just creating and editing a few files? Perhaps your company's Web Forms have some standard User Controls for header and footer HTML markup. You could create your own Web Form Wizard so that when you added a new file of the custom type, it would automatically have the standard HTML and/or code-behind class markup specific to your company!

The steps for creating a Web Form Wizard in both Visual Basic .NET and C# can be found at: Building a Custom Web Form Wizard in Visual Studio .NET. Brendan Tompkins also offers up a discussion on customizing Visual Studio .NET templates in his blog entry Visual Studio .NET Templates - Modifying Your Default Templates.

Know Your Keyboard Shortcuts

Visual Studio .NET can virtually be used without a mouse at all. There are keyboard shortcuts galore. For example, Ctrl+G will popup the "Go To Line Number" box, an invaluable tool when needing to quickly jump to a line where an error has occurred. Ctrl+Shift+A displays the Add a New Item dialog box. F5 compiles and starts the application. Ctrl+L cuts the line the cursor's at. For a reasonably good list, you can view part of the Appendix C from Mastering Visual Studio .NET (found via Ray Osherove's blog).

Store Commonly Used Code Snippets in the Toolbox

This tip comes in from Korby Parnell:
One of my favorite VS.NET productivity tricks is to store code snippets as toolbox items. Arguably, this trick is better for comments than code since you can't reference them. To add text to the Toolbox, highlight it in the code editor, drag it over to your toolbox, and drop it when the tooltip changes from the no smoking sign into rectangle. Thereafter, you can simply drag and drop the snippet to your editor for reuse.
UPDATE (Dec. 20, 2005): Visual Studio 2005 greatly improves the code snippets experience, providing a powerful mix of IntelliSense and code snippets. See Creating and Using Code Snippets in Visual Studio 2005 for more information!

Select Code Using Column Mode

This tip comes in from Arsen Yeremin:
Use ALT button while selecting to select in "COLUMN MODE".

Customize the Start Page

When Visual Studio .NET loads up, by default the Start Page is shown, which lists the most recent projects. 4Guys reader Jon Vandermeulen writes in on how to tweak VS.NET so that more than just the default four projects are shown on the Start Page:
By default, your start page only shows the last 4 projects you worked on. But if you're like us, then you would routinely work on quite a few more than that. The setting is located in Tools > Options > Environment > General > Display ___ items in most recently used list.
In addition to increasing the number of recent projects shown, you can greatly customize the entire Start Page. For more information refer to Customizing the Visual Studio .NET 2003 Start Page and Customize Visual Studio .NET's Start Page.

Using TODO, HACK, and UNDONE Comments

This tip comes in from Stephen Vakil:
I have another tip for VS. Not many people I've met know about TODO comments. When you begin a comment with ToDo or TODO or however you want to capitalize it, you can then see this comment in your task list by changing the task list options. This is very useful for marking parts of your code that you later need to work on.

By default, there is also a HACK and UNDONE comment that I use from time to time. You can add comments that can be seen on the task list by going to Tools->Options, then under the environment folder select Task List.

Split Your Document Horizontally to Reduce Vertical Scrolling and Increase Productivity While Editing
This tip arives courtesy of Chris Caputo:

Imagine editing line number 500 of a file, but needing to see what's on line 20. Splitting your view allows you to do both simultaneously, without scrolling to the top of the document.

A handy feature available in most Microsoft applications is the ability to "split" your text editor’s view, allowing you to edit or view two sections of your document at the same time. In most Microsoft applications, click on the small, flat line that sits just above the up arrow on the vertical scrollbar. Click and drag the line downward to split your window horizontally. Move it upwards to turn off this feature.


Most developers I've met and talked to throughout my career have shared one thing in common: their interest in solving problems and their disdain of the mundane. Boring, repetitive tasks are the bane of the development world, so much so that oftentimes programmers will spend countless hours constructing a solution that relieves them from some mundane chore, even if the time it takes to build a workaround is longer than the time that the boring task would require!

A common "bore chore" in development is hammering out similar code, a task good IDEs will eliminate - and Visual Studio .NET is no exception. Visual Studio .NET allows for both simple, recorded macros, as well as programmatically-created macros. To work with macros explore the Macro submenu, which is found under the Tools menu in Visual Studio .NET (seen the screenshot to the right). You can record a macro through the GUI via the Record Temporary Macro. To create a macro programmatically, choose the Macros IDE. The Macro Explorer lists all of the Visual Studio .NET macros that can be run.

For more information on creating and using Macros in Visual Studio .NET, be sure to read Improving Developer Productivity with Visual Studio .NET Macros, which looks at how to use Macros to automatically create public properties that use the ViewState collection as their backing store (a task common among ASP.NET server control developers).

For More Visual Studio .NET Tips and Tricks...
Visual Studio Hacks For more tips and tricks for Visual Studio .NET be sure to check out James Avery's book Visual Studio Hacks. The book provides 100 hacks for turbocharging the IDE.

(...Shameless self promotion alert...) I wrote five hacks for James' book: Halting on exceptions; Using the Reflector Add-In; Setting breakpoints; Spell checking your code/comments; and Generating metrics on your code (i.e., LOCs, code complexity, etc.). See this blog entry for more information.


The above list is only a smattering of tips for extending Visual Studio .NET. If you have any tips in your bag of Visual Studio .NET tricks, I'd be interested in hearing about them! Hopefully, over time, this article can become a great source for getting the most out of Visual Studio .NET.

Happy Programming!

  • By Scott Mitchell

  • ASP.NET [1.x] [2.0] | ASPMessageboard.com | ASPFAQs.com | Advertise | Feedback | Author an Article