Visual Studio .NET editor malforms HTML tags (316946)



The information in this article applies to:

  • Microsoft Visual Studio .NET (2002), Professional Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2002), Academic Edition
  • Microsoft Visual Studio .NET (2003), Professional Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2003), Academic Edition
  • Microsoft ASP.NET (included with the .NET Framework)

This article was previously published under Q316946

SYMPTOMS

In Microsoft Visual Studio .NET, you may receive a parser error under the following circumstances:
  • You use a Hypertext Markup Language (HTML) element.
  • You do not include a space between the end tag (/>) and the value of the last attribute that is located inside a <FORM> tag on a Web form in Microsoft Visual Studio .NET.
  • You open the page in your browser.
Under these circumstances, you may receive the following parser error:
Unexpected end of file looking for <FORM> tag.
This problem occurs with other HTML elements such as <A>, <LABEL>, < B >, <TEXTAREA>, and others. However, this issue was resolved for certain tags such as the <DIV> and <SPAN> tags starting with Microsoft Visual Studio .NET 2003.

CAUSE

When you switch between design view and HTML view, the Visual Studio .NET editor changes the code in your Web form, which malforms the tags. This problem only occurs when you do not include a space between the end tag (/>) and the value of last attribute of the tag.

RESOLUTION

To work around this problem, modify the tag as follows:
<FORM id="myform" method="post" runat="server">
  <SPAN id="MySpan" runat="server"></SPAN>
</FORM>
- or -
<FORM id="myform" method="post" runat="server">
  <SPAN id="MySpan" runat="server" />
</FORM>
Notice that the second code sample includes a space before the end tag (/>).

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

Steps to reproduce the behavior

  1. Create a new Visual Studio .NET Web Application project.
  2. Add a new Web form, and then open the form in HTML view.
  3. Add the following code in HTML view:
    <FORM id="myform" method="post" runat="server">
      <SPAN id="MySpan" runat="server"/>
    </FORM>
  4. Switch between design view and HTML view repeatedly. Notice that the code eventually changes to:
    <FORM id="myform" method="post" runat="server">
      <SPAN id="MySpan" runat="server">
    </FORM>
    </SPAN>
  5. Save and browse to the page.

Modification Type:MajorLast Reviewed:8/29/2005
Keywords:kbvs2002sp1sweep kbbug kbDesigner kbGrpDSASP kbhtml kbIDEProject kbpending kbWebForms KB316946 kbAudDeveloper