Commented Code Not Treated As Commented Code

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:.....
-->
 
O

Oisín Grehan

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top