|
Subject:
|
Can <!- - - -> be used to comment out aspnet code
|
|
Posted By:
|
cJeffreywang
|
Post Date:
|
4/23/2008 3:26:22 PM
|
Either <%-- --%> or <!-- --> can be used to comment out the VS 2005/ASPnet 2.0 coding?
What is the difference?
|
|
Reply By:
|
planoie
|
Reply Date:
|
4/23/2008 3:49:06 PM
|
<!-- --> is strictly an HTML comment. You could use those to hide HTML from displaying, however, I think in some cases server controls contained withing them will still be processed.
I'm not familiar with <%-- --%>. In order to comment out inline code, you'd need to use the appropriate comment char for the language:
VB - <% ' %> C# - <% // %>
-Peter peterlanoie.blog
|
|
Reply By:
|
Imar
|
Reply Date:
|
4/24/2008 1:35:28 AM
|
You can use <%-- --%> to comment out server controls in markup at the server. E.g.: this button will never make it to the browser and won't be accessible from code behind:
<%--<asp:Button ID="Button1" runat="server" Text="Button" />--%>
In contrast, an HTML comment like this:
<!-- <asp:Button ID="Button1" runat="server" Text="Button" /> -->
still makes Button1 a valid server side button that you can access in code and that makes it to the browser However, in the browser it will be seen as a plain comment:
<!-- <input type="submit" name="Button1" value="Button" id="Button1" /> -->
Try pressing Ctrl+K followed by C in VWD; it will automatically add the right code for you, regardless of where you are (ASPX, code behind, class file and so on)
HtH,
Imar
--------------------------------------- Imar Spaanjaars http://Imar.Spaanjaars.Com Everyone is unique, except for me. Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004 Want to be my colleague? Then check out this post.
|