ASPX Edit Helper Add-In For Visual Studio
The ASPX Edit Helper is an add-in for Visual Studio 2005 for those who like to type ASPX markup themselves instead of using the visual designer. It’s a very simple add-in but pretty handy if you prefer to type ASPX. (It also works with Visual Studio 2008.)
ASPX Edit Helper does just two things:
- Fill in runat=”server” id=”random_id” when you type a server control (e.g., asp:Label).
- Insert ASPX snippets when you type a short code.
Usage Type 1
Type <asp:Label and press Enter. The add-in will replace it with:
<asp:Label runat=”server” id=”asp_Label2943″ />
The add-in will also highlight the ID attribute value so you can immediately type a new ID for the control.
Alternatively, type <asp:Label></asp:Label> and press the Up or Down arrow.
Usage Type 2
Type a short code such as /lbl or /txt and press Enter. The add-in will replace it with the corresponding ASPX snippet:
<asp:Label runat=”server” id=”asp_Label2943″ />
<asp:TextBox runat=”server” id=”asp_TextBox2943″ />
The short codes and snippets are defined in the AspxEditHelperSnippets.xml file which you can crack open and modify as needed. The format for a short code must be a slash (/) followed by one or more regex word characters (\w+).
Video
You can see a brief intro video on ASPX Edit Helper at http://ardentdev.com/blog/aspxedithelper/aspxedithelper.html.
Installation
Copy the three files AspxEditHelper.AddIn, AspxEditHelper.dll, and AspxEditHelperSnippets.xml to your Visual Studio add-ins folder:
%userprofile%\Documents\Visual Studio 2005\Addins
or
%userprofile%\Documents\Visual Studio 2008\Addins
Downloads


August 7th, 2007 at 3:34 pm
Hey Derek, very handy little add-in!!!
August 8th, 2007 at 11:02 am
Hello,
%userprofile%\Documents\Visual Studio 2008\Addins does not exist for VS 2008.
Where should i place the files so that addin works in VS 2008 as well?
August 8th, 2007 at 11:15 am
Nice work! I’m curious why picked enter over tab for completing commands. Wouldn’t using tab be more consistent with the built-in VS code snippets?
August 8th, 2007 at 3:21 pm
Awesome! I wanted something like this for a long time.
Is it possible to make it trigger on “space”? For example: if type “
August 8th, 2007 at 3:58 pm
@Dragos: Just create the Addins folder if it’s not there.
@John S, @Peter: I wanted to trigger off space or tab but I didn’t find a way to do that with an add-in. The only event I could find was for LineChanged. This was my first VS add-in so if anyone knows a better way to hook changes events in the editor, please let me know!
December 7th, 2007 at 11:12 pm
Fun add-in.
Please remove the runat/id auto-complete on ListItem’s.
Thanks!
January 18th, 2008 at 7:00 pm
Very nice addin! I also had the problem with the ListItems, so I added the snippet below to AspxEditHelperSnippets.xml. Now I type “/li” and hit Enter for a listitem. I used the $id$ marker to position the cursor for editing.
li
]]>
January 18th, 2008 at 7:08 pm
Trying again, hopefully with proper html formatting this time.
<snippet>
<shortcode>li</shortcode>
<text><![CDATA[<asp:ListItem Text=”$id$” Value=”"></asp:ListItem>]]></text>
</snippet>
February 10th, 2008 at 9:50 am
Thanks Derek.
VS 2008 Addins folder is:
%ALLUSERSPROFILE%\Application Data\Microsoft\MSEnvShared\AddIns
Best regards
Anoosheh
March 6th, 2008 at 10:51 am
What a great tool :)=
Are you able to extend the addin to support adding eventhandler to server controls while in Visual Studio source view of as?c files?
I really hate to switch to design view, hightlight the control to get its properties and to select the lightning bolt from the property window… finally there i can double click to create the eventhandler. that is far too complicated.
Thanks, toebens
March 8th, 2008 at 12:45 am
toebens - you can bring up the properties window (F4) while is markup view to access events that way.
April 1st, 2008 at 11:59 am
Derek,
Very cool! Plus I love the “Not Beta” emblem on your website.
Mostafa’s comment about the location of the AddIns folder for VS2008 is correct - you might want to think about updating your instructions at the top of this page. Before I saw Mostafa’s comment I created an /AddIns folder under %userprofile%\Documents\Visual Studio 2008 and this triggered the GhostDoc configuration routine to run again next time I started VS2008.
Also, I opened up the source code and modified the way the GenerateAspxElement function creates its return value. For what it’s worth, here’s the updated code block:
If includeClosingTag = True Then
retVal = String.Format(”", tagName, controlID, tagName)
Else
retVal = String.Format(”", tagName, controlID)
End If
With this mod, if I don’t want a closing tag I can type (for example): “” or “” and hit the Enter key and ASPX Edit Helper generates: “”. If I DO want a closing tag I can leave off the closing angle bracket and just type (for example): “”
April 1st, 2008 at 12:05 pm
Hmmm… let me try that again with some HTML encoding.
Here’s the modified code block in the GenerateAspxElement function:
If includeClosingTag = True Then
retVal = String.Format("<{0} runat=""server"" id=""{1}""></{2}>",
tagName, controlID, tagName)
Else
retVal = String.Format("<{0} runat=""server"" id=""{1}""/>",
tagName, controlID)
End If
With this mod, if I don’t want a closing tag I can type (for example): "<asp:Checkbox/>" or "<asp:Checkbox>" and
hit the Enter key and ASPX Edit Helper generates: "<asp:CheckBox runat="server" id="asp_CheckBox6368"/>".
If I DO want a closing tag I can leave off the closing angle bracket and just type (for example): "<asp:DropDownList" and hit Enter and ASPX Edit Helper generates: "<asp:DropDownList runat="server" id="asp_DropDownList1946"/></asp:DropDownList>"