¿Hay una manera de comentar marcado en un.Página ASPX?


¿Hay alguna forma de comentar el marcado en una página .ASPX para que no se entregue al cliente? He probado los comentarios estándar <!-- --> pero esto solo se entrega como un comentario y no impide que el control se renderice.

Author: GEOCHET, 2008-09-23

8 answers

<%--
            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”) %>     
--%>

Fuente

 303
Author: GEOCHET,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2008-09-23 14:35:34

Respuesta adicional: El atajo de teclado en Visual Studio para comentar cualquier cosa es Ctrl-KC. Esto funciona en varios lugares, incluidas las páginas C#, VB, Javascript y aspx; también funciona para SQL en SQL Management Studio.

Puede seleccionar el texto para ser comentado, o puede colocar su texto dentro de un fragmento para ser comentado; por ejemplo, coloque su cursor dentro de la etiqueta de apertura de un GridView, presione Ctrl-KC, y todo será comentado.

 67
Author: Herb Caudill,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-05-29 20:21:17

FYI / ctrl + K, C es el atajo de comentarios en Visual Studio. ctrl + K, U uncomments.

 24
Author: Matthew M. Osborn,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-02-15 15:27:33
<%-- not rendered to browser --%>
 20
Author: Sklivvz,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-05-18 11:40:55

Sí, hay comentarios especiales del lado del servidor:

<%-- Text not sent to client  --%>
 9
Author: stefano m,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-03-24 18:35:32

Creo que estás buscando:

<%-- your markup here --%>

Es un comentario del servidor y no se entregará al cliente ... pero no es opcional. Si necesita que esto sea programable, entonces querrá esta respuesta :-)

 9
Author: Joel Martinez,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-23 12:34:31

Mientras esto funciona:

<%-- <%@ 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" %>

Esto no lo hará.

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

Así que no puedes comentar parte de algo que es lo que quiero hacer el 99.9995% del tiempo.

 8
Author: ggb667,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-11-10 19:07:18

Otra forma de asumir que no es el código del lado del servidor que desea comentar es...

<asp:panel runat="server" visible="false">
    html here
</asp:panel>
 3
Author: BigJump,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-02-15 15:28:39