Is there a way to comment out markup in an .ASPX page?

后端 未结 8 1629
暗喜
暗喜 2020-12-22 18:05

Is there a way to comment out markup in an .ASPX page so that it isn\'t delivered to the client? I have tried the standard comments

相关标签:
8条回答
  • 2020-12-22 18:47

    Another way assuming it's not server side code you want to comment out is...

    <asp:panel runat="server" visible="false">
        html here
    </asp:panel>
    
    0 讨论(0)
  • 2020-12-22 18:52

    FYI | ctrl + K, C is the comment shortcut in Visual Studio. ctrl + K, U uncomments.

    0 讨论(0)
  • 2020-12-22 18:55

    I believe you're looking for:

    <%-- your markup here --%>
    

    That is a serverside comment and will not be delivered to the client ... but it's not optional. If you need this to be programmable, then you'll want this answer :-)

    0 讨论(0)
  • 2020-12-22 18:58
    <%-- not rendered to browser --%>
    
    0 讨论(0)
  • 2020-12-22 19:07

    Bonus answer: The keyboard shortcut in Visual Studio for commenting out anything is Ctrl-KC . This works in a number of places, including C#, VB, Javascript, and aspx pages; it also works for SQL in SQL Management Studio.

    You can either select the text to be commented out, or you can position your text inside a chunk to be commented out; for example, put your cursor inside the opening tag of a GridView, press Ctrl-KC, and the whole thing is commented out.

    0 讨论(0)
  • 2020-12-22 19:09

    Yes, there are special server side comments:

    <%-- Text not sent to client  --%>
    
    0 讨论(0)
提交回复
热议问题