Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

People also ask

How do you comment out code in ASPX?

How to quickly comment and uncomment in your web pages? Select the lines you want to be commented in your ASPX, HTML, web config file etc and click on the Comment/ Uncomment icon in Toolbar. Alternatively you can use Keyboard shortcut Ctrl+K Ctrl+C to comment and use Ctrl+K Ctrl+U to uncomment.

How do I edit ASPX website?

Sometimes, the aspx files can be opened and edited with text editor. If you have free software such as Notepad++, you can open and edit the aspx files in it. Microsoft's Visual Studio is another free program that allows you to open and edit an aspx file. Adobe Dreamweaver can also open and edit an apsx file.

What are server side comments?

What is Server Side Comments? In ASP.NET MVC supports a server-side comment which make code/content completely disable in the page. ASP.NET Web Forms supports a server-side comment that you can use to completely disable content/code within a page.


<%--
            Commented out HTML/CODE/Markup.  Anything with
            this block will not be parsed/handled by ASP.NET.

            <asp:Calendar runat="server"></asp:Calendar> 

            <%# Eval(“SomeProperty”) %>     
--%>

Source


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.


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


<%-- not rendered to browser --%>

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 :-)


Yes, there are special server side comments:

<%-- Text not sent to client  --%>

While this works:

<%-- <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ht_tv1.Default" %> --%>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Blank._Default" %>

This won't.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" <%--Inherits="ht_tv1.Default"--%> Inherits="Blank._Default" %>

So you can't comment out part of something which is what I want to do 99.9995% of the time.