2008-04-23

ASP.NET Event Snippets for C# and VS 2005

Pop Quiz!
What are the fifteen page events that you can respond to in your "code behind" file in Visual Studio 2005?
What?!? You don’t have them memorized? That’s no problem if you’re a Visual Basic ASP.NET developer (you can choose them from the dropdown menu at the top of the source view), but if you are a C# ASP.NET developer, you have to type them in from memory. You must also have memorized all the events for ASMX, ASCX, MASTER, ASHX and ASAX files. That bites.
That’s why I created all ASP.NET event handlers in C# for Visual Studio 2005 as snippets, so we can automatically insert them into our code-behind files at the right-click of a mouse.
Instructions for Installation
NOTE! Make sure Visual Studio 2005 is not running while installing or uninstalling.
NOTE! Being that they are installed under "Program Files", you need administrative privileges to install the snippets – Sorry!
1. Download the ZIP file and extract the two files,
- ASPNET20Snippets.msi
- setup.exe
2. Install the snippets by double-clicking setup.exe and step through the wizard.
3. Open Visual Studio 2005.
4. Click Tools – Code Snippets Manager…
5. For the Language, choose Visual C# in the dropdown menu.
6. Click Add…
7. Be careful here! Within the dialog, browse to C:\Program Files\ASPNET20Snippets, click once on “ASP.NET Events” (don’t double-click) and click the Open button.
8. Click OK in the Code Snippets Manager dialog box to close it.
To Use
In an ASP.NET C# code-behind file, right click where you’d like to place a new event handler. Choose "Insert Snippet…", choose ASP.NET Events, choose the type of page you are working with and click the event handler that you’d like to use.
NOTE: If you want to wrap one or more lines of code with a event handler snippet, just select those lines of code before you insert the snippet. It will automatically be wrapped.
To Uninstall
1. Go to Add/Remove Programs and uninstall it.
2. Open the Code Snippets Manager in Visual Studio 2005 and remove the folder ASP.NET Events.

沒有留言:

張貼留言