Pop Quiz!
What are the fifteen Page events that you can handle in your code-behind file in Visual Studio 2005 or 2008?
What?!? You don't have them memorized? It'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 window. However, if you are a C# ASP.NET developer, you have to type them in from memory. You must also know all the events for .asmx, .ascx, .master, .ashx and .asax files. Impossible!
That's why we created Visual Studio snippets for all ASP.NET event handlers in C#. You can automatically insert them into your code-behind files with just the right-click of your mouse.
Download the installer here.
Instructions for Installation
NOTE: Make sure Visual Studio 2005 or 2008 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 installer wizard.
3. Open Visual Studio 2005 or Visual Studio 2008.
4. Click Tools | Code Snippets Manager…
NOTE: If this menu option is not available, click Ctrl-K and Ctrl-B to open the Code Snippets Manager.
5. For the Language dropdown menu, choose Visual C#.
6. Click Add…
7. Be careful here! Within this dialog box, browse to C:\Program Files\ASPNET20Snippets\, click once on the ASP.NET Events folder (don’t double-click it!) and click the Open/Select Folder 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 (ASPX, etc.) and click the event handler that you want to add.
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 or Visual Studio 2008 and remove the folder ASP.NET Events.