Jupiterimages: The premier destination for creative professionals
  When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
ASPFAQs.com
Message Board
Related Web Technologies
User Tips!
Coding Tips
Search
<a href="http://mjxads.internet.com/RealMedia/ads/click_lx.ads/intm/win/www.4guysfromrolla.com/aspnet/articles/032704-1.aspx/191107270/marketplace01/OasDefault/Persits_Software_8a/form.html/30633238633836333432636564383130?http://www.asppdf.com"><IMG SRC="http://mjxads.internet.com/RealMedia/ads/Creatives/OasDefault/Persits_Software_8a/asppdf-125x125-4a.gif" WIDTH=125 HEIGHT=125 BORDER=0></a>

Sections:
Book Reviews
?Sample Chapters
Commonly Asked Message Board Questions
Headlines from ASPWire.com
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Security
Stump the SQL Guru!
Web Hosts
XML
Information:
Advertise
Feedback
Author an Article

<a href="http://www.newideapromos.com/"><IMG SRC="http://mjxads.internet.com/RealMedia/ads/Creatives/OasDefault/New_Idea_Promos_17d/newideapromos_125x125_2_final.gif" WIDTH=125 HEIGHT=125 BORDER=0></a>

Dedicated Hosting Search Web Hosting Register Domain Name Hosting Training Franchise Directory Boat Donations Web Design Dedicated Server Compare Book Prices Internet Marketing Desktop Computers Domain Registration

internet.com
Developer
Downloads
International
Internet Lists
Internet News
Internet Resources
IT
Linux/Open Source
Personal Technology
Small Business
Windows Technology
xSP Resources

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers
ASP ASP.NET ASP FAQs Message Board Feedback
Read about a remote access solution that empowers the entire enterprise but does not require compromising versatility or security. Download this whitepaper from Nokia.
Getting the Most Out of Visual Studio .NET
By Scott Mitchell


Introduction
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.

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.

Macros
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.

Conclusion
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


    Windows Internet Technology | ASP Articles | ASPMessageboard.com | ASPFAQs.com | ASP.NET | Advertise | Feedback | Awards | Author an Article


  • JupiterWeb networks:

    internet.comearthweb.comDevx.comClickZGraphics.com

    Search JupiterWeb:

    Jupitermedia Corporation has four divisions:
    JupiterWeb, JupiterResearch, JupiterEvents and JupiterImages

    Copyright 2005 Jupitermedia Corporation All Rights Reserved.
    Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

    Jupitermedia Corporate Info | Newsletters | Tech Jobs | Shopping | E-mail Offers