开发者

ASP.net mvc how to comment out html code in page

Is there an easy way to comment out a loop which renders some html and has inline html without deleting anything? I am copying and pasting some code from another project to rebuild a new public front end from a working internal backend.

Below is an example of a sitation in which it would be nice...in asp.net MVC 2

        <% 
       List<VehicleBodyTypeListItem> lstBodyTypes = (List<VehicleBodyTypeListItem>)ViewData["ddBodyType"];
       foreach (VehicleBodyTypeListItem bodyType in lstBodyTypes)
   {
      %>
      <a href="<%= Url.Action( "Search", new { BodyTypeID=bodyType.BodyTypeID, BodyType= Url.Encode( Html.WebLinkify( bodyType.BodyType))}) + (string)ViewData["httpCriteria"] %>">
        <%= Html.Encode( String.Format( "{0} ({1})"开发者_如何学JAVA, bodyType.BodyType, bodyType.Count.ToString()))  %>        </a>
        <br />
      <%
   }
   %>

I have not completed the method that populates this list yet, and have about 5 more like it further down the page.


The keyboard shortcut is, if you select the section you want commented out is: CTRL + K + C will comment out code. CTRL + K + U will uncomment the code.


Comment a block of code by enclosing it in @* and *@


Do you mean adding comments to the code. If so you just need to add //. Like here:

            <% 
       List<VehicleBodyTypeListItem> lstBodyTypes = (List<VehicleBodyTypeListItem>)ViewData["ddBodyType"];
       foreach (VehicleBodyTypeListItem bodyType in lstBodyTypes) // Here there's a comment
   {
      %>
      <a href="<%= Url.Action( "Search", new { BodyTypeID=bodyType.BodyTypeID, BodyType= Url.Encode( Html.WebLinkify( bodyType.BodyType))}) + (string)ViewData["httpCriteria"] %>">
        <%= Html.Encode( String.Format( "{0} ({1})", bodyType.BodyType, bodyType.Count.ToString()))  %>        </a>
        <br />
      <%
   }
   %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜