Comment on an ASPX page

Discussion in 'ASP .Net Web Controls' started by Andrew Chalk, Oct 15, 2005.

  1. Andrew Chalk

    Andrew Chalk Guest

    In the HTML section of an ASPX page, how do i comment out a line?

    I thought it was <! but that doesn't work.

    Thanks!
     
    Andrew Chalk, Oct 15, 2005
    #1
    1. Advertising

  2. Andrew Chalk

    Bob Lehmann Guest

    If you did it this way it should....

    <!-- Stuff to comment -->

    Bob Lehmann

    "Andrew Chalk" <> wrote in message
    news:%...
    > In the HTML section of an ASPX page, how do i comment out a line?
    >
    > I thought it was <! but that doesn't work.
    >
    > Thanks!
    >
    >
     
    Bob Lehmann, Oct 16, 2005
    #2
    1. Advertising

  3. Hey Andrew,

    Don't forget the exclamation mark:

    <div>
    <!-- An HTML comment -->
    <%'<!-- This is an ASPX comment --> %>
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </div>


    "Andrew Chalk" <> wrote in message
    news:%...
    > In the HTML section of an ASPX page, how do i comment out a line?
    >
    > I thought it was <! but that doesn't work.
    >
    > Thanks!
    >
     
    Ken Cox [Microsoft MVP], Oct 16, 2005
    #3
  4. Andrew Chalk

    Andrew Chalk Guest

    Thanks!
    "Bob Lehmann" <> wrote in message
    news:...
    > If you did it this way it should....
    >
    > <!-- Stuff to comment -->
    >
    > Bob Lehmann
    >
    > "Andrew Chalk" <> wrote in message
    > news:%...
    >> In the HTML section of an ASPX page, how do i comment out a line?
    >>
    >> I thought it was <! but that doesn't work.
    >>
    >> Thanks!
    >>
    >>

    >
    >
     
    Andrew Chalk, Oct 16, 2005
    #4
  5. Andrew Chalk

    Andrew Chalk Guest

    But the following does not seem to work:

    <!--
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    -->

    "Ken Cox [Microsoft MVP]" <> wrote in message
    news:...
    > Hey Andrew,
    >
    > Don't forget the exclamation mark:
    >
    > <div>
    > <!-- An HTML comment -->
    > <%'<!-- This is an ASPX comment --> %>
    > <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    > </div>/
    >
    >
    > "Andrew Chalk" <> wrote in message
    > news:%...
    >> In the HTML section of an ASPX page, how do i comment out a line?
    >>
    >> I thought it was <! but that doesn't work.
    >>
    >> Thanks!
    >>

    >
    >
     
    Andrew Chalk, Oct 16, 2005
    #5
  6. Andrew Chalk

    Bob Lehmann Guest

    It work for me.
    <!-- <asp:label id="Label1" runat="server">Label</asp:label> -->
    renders as ....
    <!--<span id="Label1">Label</span>-->
    in the browser.

    Bob Lehmann

    "Andrew Chalk" <> wrote in message
    news:...
    > But the following does not seem to work:
    >
    > <!--
    > <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    > -->
    >
    > "Ken Cox [Microsoft MVP]" <> wrote in message
    > news:...
    > > Hey Andrew,
    > >
    > > Don't forget the exclamation mark:
    > >
    > > <div>
    > > <!-- An HTML comment -->
    > > <%'<!-- This is an ASPX comment --> %>
    > > <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    > > </div>/
    > >
    > >
    > > "Andrew Chalk" <> wrote in message
    > > news:%...
    > >> In the HTML section of an ASPX page, how do i comment out a line?
    > >>
    > >> I thought it was <! but that doesn't work.
    > >>
    > >> Thanks!
    > >>

    > >
    > >

    >
    >
     
    Bob Lehmann, Oct 16, 2005
    #6
  7. Hi,

    The reason why your example does not "work" is because the ASP.NET page
    parser does not see that the label is within HTML comments. Thus, it will
    output the 'normal' HTML inbetween the label tags.

    For you to comment on server controls, you could try the following:

    C#: <% // <asp:label runat="server" /> %>
    VB.NET: <% ' <asp:label runat="server" /> %>

    I hope that helps,
    Justin

    "Andrew Chalk" <> wrote in message
    news:...
    > But the following does not seem to work:
    >
    > <!--
    > <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    > -->
    >
    > "Ken Cox [Microsoft MVP]" <> wrote in message
    > news:...
    >> Hey Andrew,
    >>
    >> Don't forget the exclamation mark:
    >>
    >> <div>
    >> <!-- An HTML comment -->
    >> <%'<!-- This is an ASPX comment --> %>
    >> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    >> </div>/
    >>
    >>
    >> "Andrew Chalk" <> wrote in message
    >> news:%...
    >>> In the HTML section of an ASPX page, how do i comment out a line?
    >>>
    >>> I thought it was <! but that doesn't work.
    >>>
    >>> Thanks!
    >>>

    >>
    >>

    >
    >
     
    Justin Lovell, Oct 16, 2005
    #7
  8. Andrew Chalk

    clintonG Guest

    Try the documentation [1].

    If you're using Visual Studio you can apply and remove server-side comments
    using tools on the Standard toolbar.
    I also use Ctrl-K/Ctrl-C and Ctrl-K/Ctrl-U noting VS2005 Beta 2 which I
    continue to use until RTM remains somewhat buggy when trying to
    Ctrl-K/Ctrl-U to remove comments. More keyboard shortcuts can be reviewed
    here [2] as well as other sites.

    To avoid problems use the server-side comment syntax Microsoft recommends.

    <%= Clinton Gallagher
    METROmilwaukee (sm) "A Regional Information Service"
    NET csgallagher AT metromilwaukee.com
    URL http://metromilwaukee.com/
    URL http://clintongallagher.metromilwaukee.com/

    [1]
    http://msdn.microsoft.com/library/d...us/cpgenref/html/cpconserver-sidecomments.asp
    [2] http://safari.oreilly.com/?XmlId=0-596-00360-9/mastvsnet-APP-C



    "Andrew Chalk" <> wrote in message
    news:%...
    > In the HTML section of an ASPX page, how do i comment out a line?
    >
    > I thought it was <! but that doesn't work.
    >
    > Thanks!
    >
     
    clintonG, Oct 17, 2005
    #8
  9. Andrew Chalk

    Andrew Chalk Guest

    Thanks. That works and explains a lot about commenting.

    - A

    "Justin Lovell" <> wrote in message
    news:%...
    > Hi,
    >
    > The reason why your example does not "work" is because the ASP.NET page
    > parser does not see that the label is within HTML comments. Thus, it will
    > output the 'normal' HTML inbetween the label tags.
    >
    > For you to comment on server controls, you could try the following:
    >
    > C#: <% // <asp:label runat="server" /> %>
    > VB.NET: <% ' <asp:label runat="server" /> %>
    >
    > I hope that helps,
    > Justin
    >
    > "Andrew Chalk" <> wrote in message
    > news:...
    >> But the following does not seem to work:
    >>
    >> <!--
    >> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    >> -->
    >>
    >> "Ken Cox [Microsoft MVP]" <> wrote in message
    >> news:...
    >>> Hey Andrew,
    >>>
    >>> Don't forget the exclamation mark:
    >>>
    >>> <div>
    >>> <!-- An HTML comment -->
    >>> <%'<!-- This is an ASPX comment --> %>
    >>> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    >>> </div>/
    >>>
    >>>
    >>> "Andrew Chalk" <> wrote in message
    >>> news:%...
    >>>> In the HTML section of an ASPX page, how do i comment out a line?
    >>>>
    >>>> I thought it was <! but that doesn't work.
    >>>>
    >>>> Thanks!
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
     
    Andrew Chalk, Oct 17, 2005
    #9
  10. Andrew Chalk

    clintonG Guest

    That's a kludged hack. Why don't you learn how to comment correctly? Once
    you learn the keyboard commands the same command set can be used in HTML and
    in the source code.

    Does my reply not show up in your reader?

    <%= Clinton Gallagher
    METROmilwaukee (sm) "A Regional Information Service"
    NET csgallagher AT metromilwaukee.com
    URL http://metromilwaukee.com/
    URL http://clintongallagher.metromilwaukee.com/




    "Andrew Chalk" <> wrote in message
    news:...
    > Thanks. That works and explains a lot about commenting.
    >
    > - A
    >
    > "Justin Lovell" <> wrote in message
    > news:%...
    >> Hi,
    >>
    >> The reason why your example does not "work" is because the ASP.NET page
    >> parser does not see that the label is within HTML comments. Thus, it will
    >> output the 'normal' HTML inbetween the label tags.
    >>
    >> For you to comment on server controls, you could try the following:
    >>
    >> C#: <% // <asp:label runat="server" /> %>
    >> VB.NET: <% ' <asp:label runat="server" /> %>
    >>
    >> I hope that helps,
    >> Justin
    >>
    >> "Andrew Chalk" <> wrote in message
    >> news:...
    >>> But the following does not seem to work:
    >>>
    >>> <!--
    >>> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    >>> -->
    >>>
    >>> "Ken Cox [Microsoft MVP]" <> wrote in message
    >>> news:...
    >>>> Hey Andrew,
    >>>>
    >>>> Don't forget the exclamation mark:
    >>>>
    >>>> <div>
    >>>> <!-- An HTML comment -->
    >>>> <%'<!-- This is an ASPX comment --> %>
    >>>> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    >>>> </div>/
    >>>>
    >>>>
    >>>> "Andrew Chalk" <> wrote in message
    >>>> news:%...
    >>>>> In the HTML section of an ASPX page, how do i comment out a line?
    >>>>>
    >>>>> I thought it was <! but that doesn't work.
    >>>>>
    >>>>> Thanks!
    >>>>>
    >>>>
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
     
    clintonG, Oct 18, 2005
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Smith

    how to comment-out aspx code

    John Smith, Oct 4, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    15,469
    John Smith
    Oct 6, 2004
  2. John M
    Replies:
    1
    Views:
    1,190
    Kumar Reddi
    May 29, 2005
  3. Alec S.
    Replies:
    10
    Views:
    10,169
    Alec S.
    Apr 16, 2005
  4. KevinGPO
    Replies:
    0
    Views:
    385
    KevinGPO
    Feb 17, 2006
  5. David Thielen

    How do I comment out stuff in an aspx file

    David Thielen, May 28, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    327
    Walter Wang [MSFT]
    May 29, 2006
Loading...

Share This Page