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/aspxedithelperfiles/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>"
May 23rd, 2008 at 12:03 pm
I keep getting the following error every time I try to get it to run in VS2008. I tried placing the files here to no avail (VS will not even recognize it - even though DevExpress dll is also there and it works):
C:\Documents and Settings\All Users\Application Data\Microsoft\MSEnvShared\Addins
I then tried creating the folder (Addins) as above (\Visual Studio 2008\Addins), then this happens (error).
—————————
Microsoft Visual Studio
—————————
The Add-in ‘ASPX Edit Helper’ failed to load or caused an exception.
Would you like to remove this Add-in?
If you choose yes, the file it was loaded from, ‘H:\Visual Studio 2008\Addins\AspxEditHelper.AddIn’, will be renamed.
Error Message:
Error number: 8013150a
—————————
Any ideas why this could be?
Mozes
May 23rd, 2008 at 12:06 pm
Ok, I think I see what is going on. My Documents folder is mapped to a remote drive. When I reset things to the local drive, it works. Is there any support for a mapped drive (company policy)?
June 11th, 2008 at 5:30 am
Mozes,
I faced the same problem with another addin. Try copying the .addin file and the dll in the folder C:\Documents and Settings\All Users\Application Data\Microsoft\MSEnvShared\Addins, it worked for me. The Application Data folder is hidden.
June 17th, 2008 at 7:15 am
Wow - what a nice tool. If only clients knew how much money you’ve just saved them on a per-hour project!
Thanks Derek.
June 19th, 2008 at 4:34 pm
Thank you so much. This tool is wonderful.
And thank you for the source code, Now I can add as many of these that I want.
August 27th, 2008 at 10:50 am
Hi, this looks very useful, thanks!
I have a question for which I’ve not found an answer absolutely anywhere: at some point something in my VS2005 changed so that, whenever I double-click on an ASPX file in the Solution Explorer, it always opens the page in design view instead of HTML markup edit view. Like you, I much prefer working with the markup directly.
Any idea how to change this setting??
Sorry for the off-topic post but the people here sound like precisely the ones who’d be able to help me out ;-)
Tian
August 29th, 2008 at 8:34 am
In answer to my own question: I found the solution and if you don’t mind I’ll document it here for those other lost souls to find via the big G…
In VS2005 Solution Explorer, right-click on any .aspx file, choose “Open with…” In the dialog, tick “Source (Text) Editor”, tick “Set as default”, click “OK”.
You’re in business - no more poxy design view.
November 3rd, 2008 at 5:28 pm
Thank you so much for this. I cannot afford CodeRush and have been looking for this forever.
February 20th, 2009 at 3:08 pm
I’m having trouble getting the plugin to work in VS2008. I’ve added the add-in to C:\Documents and Settings\All Users\Application Data\Microsoft\MSEnvShared\Addins as suggested above. The add-in shows up in the Add-in Manager, but doesn’t seem to work. Any ideas?
February 20th, 2009 at 11:18 pm
ok, i got it to work…simply needed to press “enter”. sorry for not reading the instructions thoroughly enough.
May 5th, 2009 at 4:35 am
Downloading right now! So curious. I love typing aspx markup !