[Mono-bugs] [Bug 517656] HTML comment in ASPX file causes "Literal content not allowed for System.Web.UI.WebControls.ListItemCollection" Exception

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Jun 30 02:35:17 EDT 2009


User spam at sigphi.ca added comment

--- Comment #2 from Justin Malcolm <spam at sigphi.ca>  2009-06-30 00:35:16 MDT ---
The issue is really more generally that HTML comments are being parsed for
correct ASP.NET mark-up when they should just be ignored.

For example, the very short ASPX file below:

<%@ Page Language = "C#" %>
<p>HTML comment representing bad ASP.NET mark-up to follow...</p>
<asp:textbox id='testBox' runat='server' />
<p>Ok, we are past that nasty comment.</p>

results in the following exception:

Server Error in '/main' Application
Control 'testBox' of type 'TextBox' must be placed inside a form tag with

Description: HTTP 500. Error processing request.

Stack Trace:

System.Web.HttpException: Control 'testBox' of type 'TextBox' must be placed
inside a form tag with runat=server.
  at System.Web.UI.Page.VerifyRenderingInServerForm (System.Web.UI.Control
control) [0x00000] 
  at System.Web.UI.WebControls.TextBox.AddAttributesToRender
(System.Web.UI.HtmlTextWriter w) [0x00000] 
  at System.Web.UI.WebControls.WebControl.RenderBeginTag
(System.Web.UI.HtmlTextWriter writer) [0x00000] 
  at System.Web.UI.WebControls.TextBox.Render (System.Web.UI.HtmlTextWriter w)
  at System.Web.UI.Control.RenderControl (System.Web.UI.HtmlTextWriter writer)
  at System.Web.UI.Control.RenderChildren (System.Web.UI.HtmlTextWriter writer)
  at System.Web.UI.Control.Render (System.Web.UI.HtmlTextWriter writer)
  at System.Web.UI.Page.Render (System.Web.UI.HtmlTextWriter writer) [0x00000] 
  at System.Web.UI.Control.RenderControl (System.Web.UI.HtmlTextWriter writer)
  at System.Web.UI.Page.RenderPage () [0x00000] 
  at System.Web.UI.Page.InternalProcessRequest () [0x00000] 
  at System.Web.UI.Page.ProcessRequest (System.Web.HttpContext context)

Version information: Mono Version: 2.0.50727.1433; ASP.NET Version:

Why would I need to add a <form> tag inside my comments?

Anyway, pretty simple to work around now that I understand what is happening.

It almost stopped me from upgrading to Mono 2.4.2 though as I just did not want
to be bothered trying to understand why pages written months ago stopped
working.  The HTML comment in question was originally buried in quite a long

I doubt that I am the only one with bad mark-up in comments.

Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.

More information about the mono-bugs mailing list