Are these comments or not?

joe_pool_is

Well-known member
Joined
Jan 18, 2004
Messages
451
Location
Texas
Are the following lines comments or exectuable code in an ASP.NET file?

Code:
<!-- #include file=~/imageswap.html -->
<!--<asp:HyperLink ID="HyperLink10" runat="server" NavigateUrl="~/About/BrucesBrew.aspx"><asp:Image ID="WhatsBrewingPhoto" runat="server" ImageUrl="~/Images/Common/Extras/WhatsBrewing/WhatsBrewingPhoto01.jpg" BorderWidth="0" /></asp:HyperLink> -->
<%--<asp:Image ID="WhatsBrewingLS" runat="server" ImageUrl="~/Images/Common/Extras/WhatsBrewing/WhatsBrewingLeftSpacer.gif" BorderWidth="0" /><asp:ImageButton ID="BrewingPrevious" runat="server" ImageUrl="~/Images/Common/Extras/WhatsBrewing/WhatsBrewingPrevious.gif" BorderWidth="0" /><asp:ImageButton ID="BrewingNext" runat="server" ImageUrl="~/Images/Common/Extras/WhatsBrewing/WhatsBrewingNext.gif" BorderWidth="0" /><asp:Image ID="WhatsBrewingRS" runat="server" ImageUrl="~/Images/Common/Extras/WhatsBrewing/WhatsBrewingRightSpacer.gif" BorderWidth="0" /><br />--%>

Im supposed to be fixing this ASP.NET site that someone else built and we dont have the project for it.

But I honestly dont know that much about the technology.
 
Code:
<!-- #include file=~/imageswap.html -->
is including the file ~/imageswap.html into the current file and is not a comment while I think the other two lines are comments :confused:

If you delete each of those lines in turn does it break anything?
 
Are the following lines comments or exectuable code in an ASP.NET file?

Code:
<!-- #include file=~/imageswap.html -->
<!--<asp:HyperLink ID="HyperLink10" runat="server" NavigateUrl="~/About/BrucesBrew.aspx"><asp:Image ID="WhatsBrewingPhoto" runat="server" ImageUrl="~/Images/Common/Extras/WhatsBrewing/WhatsBrewingPhoto01.jpg" BorderWidth="0" /></asp:HyperLink> -->
<%--<asp:Image ID="WhatsBrewingLS" runat="server" ImageUrl="~/Images/Common/Extras/WhatsBrewing/WhatsBrewingLeftSpacer.gif" BorderWidth="0" /><asp:ImageButton ID="BrewingPrevious" runat="server" ImageUrl="~/Images/Common/Extras/WhatsBrewing/WhatsBrewingPrevious.gif" BorderWidth="0" /><asp:ImageButton ID="BrewingNext" runat="server" ImageUrl="~/Images/Common/Extras/WhatsBrewing/WhatsBrewingNext.gif" BorderWidth="0" /><asp:Image ID="WhatsBrewingRS" runat="server" ImageUrl="~/Images/Common/Extras/WhatsBrewing/WhatsBrewingRightSpacer.gif" BorderWidth="0" /><br />--%>

Im supposed to be fixing this ASP.NET site that someone else built and we dont have the project for it.

But I honestly dont know that much about the technology.

I know this is a semi-old thread (sort of), but I wanted to answer it, so others arent confused.

Code:
<!-- #include file=~/imageswap.html -->
This line will include a file for you. Since theres a tilde (~) and the beginning, it will start at the root and go through the directory structure to your location. So this is looking for imageswap.html in the root of the website.

Code:
<!--<asp:HyperLink ID="HyperLink10" runat="server" NavigateUrl="~/About/BrucesBrew.aspx"><asp:Image ID="WhatsBrewingPhoto" runat="server" ImageUrl="~/Images/Common/Extras/WhatsBrewing/WhatsBrewingPhoto01.jpg" BorderWidth="0" /></asp:HyperLink> -->
This line will process your ASP.NET object (in this case, two HyperLinks and an Image) but when it processes it, it will be placed in a comment block and be invisible to the visitor. Viewing the source of the page will still yield HTML code associated with this.

Code:
<%--<asp:Image ID="WhatsBrewingLS" runat="server" ImageUrl="~/Images/Common/Extras/WhatsBrewing/WhatsBrewingLeftSpacer.gif" BorderWidth="0" /><asp:ImageButton ID="BrewingPrevious" runat="server" ImageUrl="~/Images/Common/Extras/WhatsBrewing/WhatsBrewingPrevious.gif" BorderWidth="0" /><asp:ImageButton ID="BrewingNext" runat="server" ImageUrl="~/Images/Common/Extras/WhatsBrewing/WhatsBrewingNext.gif" BorderWidth="0" /><asp:Image ID="WhatsBrewingRS" runat="server" ImageUrl="~/Images/Common/Extras/WhatsBrewing/WhatsBrewingRightSpacer.gif" BorderWidth="0" /><br />--%>
Finally, this line will COMPLETELY ignore any code. I dont even think its processed on the servers end.

Since HTML is client-side, ASP.NET objects are processed before being displayed, so <%-- --%> is to ASP.NET as <!-- --> is to HTML.

I hope this helps!

~Derek
 
Thanks Derek,

This is an ongoing project that I occasionally get a call to do some fixes or updates to (you are welcome to take over, if you are interested).

I tried removing these lines, thinking they were comments, and the page simply did not work. I new there was something else involved, but symbols (like <!-- --> and <%-- --%>) are difficult to look up in a search engine.
 
Thanks Derek,

This is an ongoing project that I occasionally get a call to do some fixes or updates to (you are welcome to take over, if you are interested).

I tried removing these lines, thinking they were comments, and the page simply did not work. I new there was something else involved, but symbols (like <!-- --> and <%-- --%>) are difficult to look up in a search engine.

I hear you on that one!

Im glad I came across this post, though. Gives me a topic to blog about :D

~Derek
 
Back
Top