Commented Code Not Treated As Commented Code

  • Thread starter Thread starter Jim Heavey
  • Start date Start date
J

Jim Heavey

Hello, I thought I was loosing my mind. I had a page which was working
perfectly fine until I decided to try to add a control to a footer line in
code. So I took the Validation control which was embedded in my .aspx file
and moved it to the very bottom of the page and placed the "<!--" prior to
beginning of the <asp:... and then I placed a "-->" after the closing tag
of my control. Just want to ensure that I could add it in code first prior
to completly removing the control.

Every time I ran, I would get an unhandled exception indicating that the it
could not find the control referenced in my "ControlToValidate". So I
commented out the code which was adding the control in code and ran again.
But again, I would get the same error.

Then I removed my "Commented" code and it ran just fine.

Why is ASP trying to do anything with the line which is surrounded by the
"comment" characters?

Example:

<!--
<asp:.....
-->
 
That is client-side commenting, it is ignored with server side code. You
need to use server-side comments:

<%-- <asp:label runat="server" /> --%>

Hope this helps,

- Oisin
 
Back
Top