Frans Bouma's blog

Generator.CreateCoolTool();

Syndication

News



    Visit LLBLGen Pro's website

    Follow me on Twitter

    Add to Technorati Favorites

About me

Fun stuff I created

My work

Serious ASP.NET Editor flaw lives on in VS.NET 2003

Several (ok, a lot) of people have been bitten by the "I-format-your-HTML-code-as-I-please"-bug in the ASP.NET HTML editor in Visual Studio.NET v2002. To recap what the bug does to you: you are working in HTML view on a page. You have to do this because f.e. you are working on a repeater template. Because you are a good developer, you create a readable layout of your code, so also for this HTML. When you come to the point where you have to add a control to your ASP.NET page, you have to switch over to design view, drag it from the toolbox onto the page, switch back to HTML view to add f.e. templates or additional properties or even position it correctly. When you switch back from design view to HTML view, your code sometimes (not allways) gets reformatted randomly, even if you switch off any auto-formatting feature in Visual Studio.NET. Hitting control-z undo's this formatting, but it gets annoying over time.

When Visual Studio.NET 2003 hit the streets, people were expecting a fix for this bug. However... it's still there. Someone started a thread about this in the microsoft.public.vsnet.general newsgroup, demanding an explanation about this behaviour and why it wasn't fixed (because literally hundreds of people have posted this bug in that said newsgroup before). The complete thread can be found here.

Today, Mike Moore of Microsoft posted a new posting in that thread about his investigations about this matter, and it might be of interest to some of you so I'll post the message directly.

(c) Mike Moore/Microsoft.
SUMMARY
This thread is discussing a problem with the Visual Studio .NET development environment for ASP.NET. If you type directly into the HTML view of the ASPX page, sometimes VS will reformat what you have typed. As is shown by the other posts in this thread, this bug is affecting many people.

We already discussed two "partial" workarounds. These help, but do not fix the problem. I also wrote that I would try to find out more about why we did not fix this problem with the release of VS 1.1.

These are the workarounds.

1) Undo
Each time you return to HTML view, immediately run Undo. The formatting changes mostly take place when you switch from design view to HTML view and these changes are mostly in a single undo entry. Calling undo then reverses many of the changes.

2) Save
Saving the ASPX page just prior to switching to design view reduces the amount of reformatting the next time you switch back to HTML view.

---
Regarding the explanation, I first want to apologize for taking so long to get back to you all.

I found that the development team did seriously consider this bug. The first thought was to add an option to turn off the reformatting feature. Unfortunately, it turned out to be deeply integrated in the code that makes the editor useful. So, it could not be turned off. Nor could it easily be fixed. Any changes made to this area of the code would definitely impact many aspects of the editor.

If they could go back in time and rethink that decision, things might be otherwise. However, at the time, the development team looked at all the information they had available and decided that trying to fix this for the 1.1 release would cause more harm than good.

My opinion about this can be read in the thread linked, but to sum it up: I'm very dissapointed. It's a text-editor for crying out loud. If you can't preserve tabs in text, something is seriously wrong. And what's worse: this won't be fixed until next major release of Visual Studio.NET, which will not see the light of day before Q2 2004.

Published Thursday, May 15, 2003 12:01 PM by FransBouma

Filed under:

Comments

# re: Serious ASP.NET Editor flaw lives on in VS.NET 2003@ Thursday, May 15, 2003 12:06 AM

Maybe as an interim solution they could fix the problem in the upcoming release of the Web Matrix.

Ron Green

# Frans Bouma's blog@ Thursday, May 15, 2003 6:01 AM

Frans Bouma's blog

TrackBack

# re: Serious ASP.NET Editor flaw lives on in VS.NET 2003@ Sunday, September 21, 2003 9:57 PM

This bug was making me very upset and I could not understand why it was still happening, even though I had turned off all auto-formatting options in VS.NET. I just found out that is a well-known bug.

Not only the editor is having this irritating "I-will-do-it-for-you” behavior, but also the final "smart" formatting that is applied is (usually) completely messed up. A child programmer would have done better.

A workaround that I have been using, whenever the editor messes up the HTML code, is to copy and paste the HTML code to an blank XML file, apply the XML auto-formatting (with line breaks) and copy it back to the HTML. The XML auto-formatting feature is much more intelligent and neat than the HTML one and, usually, complies with my HTML indentation style.
I hope the hint helps someone else.

Marcos

Marcos Nowosad

# re: Serious ASP.NET Editor flaw lives on in VS.NET 2003@ Friday, November 14, 2003 9:10 AM

First, thanks for a good summary of the issue. Microsoft has had many major flaws in their systems, which is not unexpected considering the sheer volume and scope of them. Professional programmers understand that and can live with it. That's not the real problem. When a major flaw is found by the first person, Microsoft SHOULD be telling everyone about it in any way they can so every single programmer doesn't have to waste time finding it anew. As usual though, they take what can only be described as an immature approach and make a point of minimizing it to the point where you have to search and search just to get the REAL scoop from some user posting. "Flaw? What Flaw? Oh, you mean THAT flaw. Well, yeah, of course we knew about it and now that you mention it, let me tell you all about it..." Just to drive home the importance of this particular flaw, it isn't just that the text gets bunched together in an unreadable format. The formatter actually rearranges the tags within a control's specificatins. For me, I have a dropdownlist on a page used to edit a record, and set the datasource using a function in the codebehind page. I also set the current index value using another function. So I have a "datasource =" and a "selectedindex =" within the dropdownlist tags, so when the screen comes up, the dropdownlist contains all the available selections and is sitting on the one currently selected for that record. The reformatting actually moves the selectedindex IN FRONT OF the datasource specification. Since the entire point of a tagging system is that it is NON-POSITIONAL, what moron even considered altering the coding in this way? The interpreter is also flawed, because it takes in this new line of code and reconciles the tags from left to right! So basically, my "adjusted" code now tries to set the selectedindex of a datasource that doesn't exist yet, and the program crashes. As for Mike's statement, give me a break. This is ASP.NET, the entire foundation of which is that editor. It's obvious from the example I just mentioned that the reformatting is reading the controls in by tagset, analyzing them for "reformatting" and writing them back. It just happens to be totally screwing up the "writing back" part. Now we're being told that the integration is too deep? All I can say is, Mike, stop treating the experienced programmers of the world like idiots. It's more likely that Microsoft has done what they usually do, which is to put out a brand new product with version "1" before it is really ready, to beat the competition and coordinate with their other schedules. Then they move almost all the knowledgeable staff onto the Version 2 project and leave a support staff handling updates and bug-hunts and as Mike is doing, just plain stalling until Version 2 is ready. Here's a few things Mike could do in a quick service pack that are really easy: Since there are checkboxes that supposedly control the autoformatting in Tools/Options, but DON'T, take them out. It just means making them invisible and they must have somebody there who can handle that. When this service pack is installed, include a document that completely describes this problem and all of the other ones like it that I haven't personally found yet. Since that is just typing, they should be able to handle that as well. Unless of course, their keyboards are too deeply integrated into their editors....

FC

# re: Serious ASP.NET Editor flaw lives on in VS.NET 2003@ Sunday, December 07, 2003 4:32 PM

I've been doing web design in asp for nearly 3 years and I'm now migrating to asp.net. All I can say is that this bug shows how pathetic microsoft's visual studio design team is and its OBVIOUS none of them have ever done any real web dev in their careers. I also dont know how a bug like this could get past the testing level unless it was completely ignored for reasons stated by Mike Moore in his letter. This bug is seriously so annoying it makes me want to stab out my eyeballs with a rusty spoon. It makes the design view completely useless for everyone but newbies who create their high school web project from an oreilly asp.net book.

matt

# re: Serious ASP.NET Editor flaw lives on in VS.NET 2003@ Thursday, December 11, 2003 2:48 PM

I am using Visual Studio 2003 and it looks like this problem is fixed. In old Visual Studio it used to strip "Style" in <td> tag, but it's no longer doing it.

Can someone verify this?

Thanks.

Jim

Jim Han

# re: Serious ASP.NET Editor flaw lives on in VS.NET 2003@ Tuesday, December 23, 2003 11:29 PM

Not only is this an annoying bug but I've got one worse. For some reason, the event wiring code that hooks buttons and other control's postback events to the code behind .cs file, dissapears, seemingly randomly, when a .aspx file is saved. Doesn't happen everytime but when the client calls up and says some button doesn't work anymore, it really sucks.

And that explanation for why the bug didn't get fixed is such BS. How many billions in cash does MS have in the bank? Hire consultants if your team is too la.. uh, uh, unable to rewrite the code.

Rip Ryness

# re: Serious ASP.NET Editor flaw lives on in VS.NET 2003@ Tuesday, December 30, 2003 8:27 PM

I have stopped all major development with asp.net until this bug is fixed.

Danny Jones

# re: Serious ASP.NET Editor flaw lives on in VS.NET 2003@ Thursday, January 08, 2004 12:56 PM

I am also having issues with the .net HTML editor, in addition to the automatic formatting problem. Has anyone expereinced the disappearance of OnClick events, set in asp:imagebutton properties, upon saving HTML formatting changes in .net???

Diana

# Diana - Yes @ Wednesday, January 14, 2004 2:46 PM

See my comment just above yours. This bug has bit me several times.

It really sucks to get a bug report from a client on something that worked yesterday.

Rip Ryness

# re: Serious ASP.NET Editor flaw lives on in VS.NET 2003@ Tuesday, February 03, 2004 6:35 AM

Having Used Dreamweaver to create asp.net pages before using vs.net I was appalled at how difficult it was to do the most simple of things, i was ending up designing the page in dreamweaver and then adding the code behind afterwards (vs.net didn't like this either but it did help a bit) I really do hope they can sort this problem out for the next version and the manipulation of tables (quite a simple task but very irritating). Maybe some better css integration as well (we can but dream!!!)

caveman_dick

# re: Serious ASP.NET Editor flaw lives on in VS.NET 2003@ Tuesday, February 03, 2004 6:42 AM

The next version (whidbey) is really nice, they definitely are doing a great job fixing all the poop they sold us and are selling us even today.

But that's the future of course, it's not helping us today.

Caveman: you can select dreamweaver as the default html editor in vs.net. I have done that with homesite. Of course you have to manually tie controls to event handlers and have to declare them by hand in the code behind, but for the rest it's pretty seamless.

Frans Bouma

# Microsoft support? Where?@ Friday, February 06, 2004 6:33 AM

TrackBack

# re: Serious ASP.NET Editor flaw lives on in VS.NET 2003@ Friday, February 13, 2004 5:20 PM

After waiting nearly two years to jump to the .NET boat, and only three days of actual coding time, I'm thoroughly disgusted with VS.NET. How the heck am I supposed to master code-behind if code-in-front can't even stay together? It can't keep 50 lines of simple HTML in order. I've used InterDev for years for classic ASP (without using the DTCs because they're broken). I looked forward to VS.NET because all the design-time controls were supposed to work. Finally. Well. Hmmm. I'm about ready to quit .NET, too...it's bad enough that I have 30,000 lines of ASP code to move over; I don't need to fight the IDE too.

Tim

# re: Serious ASP.NET Editor flaw lives on in VS.NET 2003@ Thursday, February 19, 2004 10:54 PM

Here is something odd to check out. I wrote the following line in html and switched to design without saving, then switched back to html.
<a href='javascript:windowHandle = window.open("http://www.yahoo.com","_blank","width=400,height=400,resizable=yes,toolbar=yes,menubar=yes,location=no,scrollbars=yes"">http://www.yahoo.com","_blank","width=400,height=400,resizable=yes,toolbar=yes,menubar=yes,location=no,scrollbars=yes");windowHandle.focus();'><u>View Map</u></a>

If you hit save before switching views or use the following line - single and double quotes are reversed - it works perfectly.

<a href="javascript:windowHandle = window.open('http://www.yahoo.com','_blank','width=400,height=400,resizable=yes,toolbar=yes,menubar=yes,location=no,scrollbars=yes');windowHandle.focus();"><u>Yahoo</u></a>

Matt

# re: Visual Studio 2005 = @ Saturday, March 13, 2004 11:36 PM

TrackBack

# re: Visual Studio 2005 = @ Tuesday, March 16, 2004 3:34 PM

TrackBack

# re: Serious ASP.NET Editor flaw lives on in VS.NET 2003@ Monday, April 12, 2004 12:18 PM

im very dissapointed. vs.net is supposed to be a "production ready" IDE. i've lost hours to this bug. if it were up to me, i'd be doing php in jedit.

johan

# re: Serious ASP.NET Editor flaw lives on in VS.NET 2003@ Saturday, April 17, 2004 5:20 AM

The editor also has problems with inline styles:

<img style="position: absolute; top: <%= SomeValue %>" src="/img.gif">

When switching back and forth from design to html view, the 'top: <%= SomeValue %>' part gets completely removed...

Panayot Belchev

# Fun bug@ Thursday, May 06, 2004 12:49 PM

Took me over 20 mins to find this post and I'm glad I did. What a POS that M$ doesn't fix a problem they knew was there. Still no work-arounds, patches, or fixes for this problem one year later? WTF?

Don

# Fun bug 2...wish I could...@ Thursday, May 06, 2004 1:20 PM

Man this issue really bothers me as I think about it more. What kind of a development team says "ah, the bug is just too big to fix?" Seriously, think about development you've all done and I'm sure you've never said "well, it's just too big of a bug to bother with - I'll fix the small ones, though." I don't care how big of a bug it is! If it's a known HUGE bug (like it obviously is) THEN MAKE IT WORK!

Don

# re: Serious ASP.NET Editor flaw lives on in VS.NET 2003@ Friday, May 28, 2004 8:34 PM

Thanks for posting info about this bug. It's been driving me absolutely nuts. At first I thought I didn't have my IDE settings configured properly. Now I know that it's a .NET bug and others have been going through the same frustration as me.

Kevin

# Copying an input and pasting in file to modify later, .NET editor changes the ids of controls!!@ Sunday, June 06, 2004 5:14 PM

Please help me turn this feature off! When I paste an <input/> with an id attribute, the .NET editor replaces the id with a unique one, even though I am going to delete the other part, or use it in a modified way.

Sam

# re: Serious ASP.NET Editor flaw lives on in VS.NET 2003@ Friday, June 11, 2004 5:19 PM

<a href="http://weblogs.asp.net/MikhailArkhipov/archive/2004/05/16/132886.aspx"> Here is a more detailed explaination</a>

Phillip

# re: Serious ASP.NET Editor flaw lives on in VS.NET 2003@ Monday, June 14, 2004 5:29 PM

Man, this bug drives me craaazy! Maybe Microsoft should take a look at Dreamweaver or GoLive, and see how a proper editor will never alter your formatting.

murk

# re: Serious ASP.NET Editor flaw lives on in VS.NET 2003@ Tuesday, June 22, 2004 2:50 PM

This bug has cost the company I'm working for countless man hours, and a whole crap load of $$$.

Thanks Microsoft.

John Raab

# re: Serious ASP.NET Editor flaw lives on in VS.NET 2003@ Tuesday, July 06, 2004 2:23 PM

I find myself every few months checking in on this problem in the hope that MS would do the right thing and release a fix but as always has happened over the last 2 years I am still waiting. I have always been an early adopter of new MS technologies in the past and have seen my fair share of bugs but I can't remember ever being more frustrated for such a long period of time as with this bug. With the new version on the horizon I am going to have to answer the question "Do I want to trust MS again?". Damn good question!

Dean

# re: Serious ASP.NET Editor flaw lives on in VS.NET 2003@ Wednesday, July 14, 2004 4:31 PM

I found this thread Googling for "pasting changes id value .net" and thought I'd pass along a link I came across. Its an Add-in someone created to prevent the HTML editor from adding the ID attribute to various controls when pasting markup into the editor pane.

While I don't seem to have that problem in my current version of Studio, I do still fight daily with the editor changing the ID values upon pasting. It looks like the solution in this link might be fertile ground for solving that problem, too.

They call it the "what is in the clipboard is what get(sic) pasted" Add-in.

http://www.codeproject.com/macro/wiicwgp.asp

Hope this helps some folks.

Kirk