468,554 Members | 1,393 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,554 developers. It's quick & easy.

including comments in ASPX code that don't render to the client? (c# 2.0)

In .NET 2.0, is there any way to include comments in the aspx file
that do not get rendered to the client (ie no <!-- -->) ?

When I try to include C# comments in a code block in an aspx page,
like this:

<%
// ************************************************** *****
// CHANGE HISTORY:
// DATE USER CHANGE
// 08/14/2007 Tue ebloom updated logo
// ************************************************** *****
%>

I am getting an error

The Controls collection cannot be modified because the control
contains code blocks (i.e. <% ... %>).

It would seem this is because .NET doesn't like inline code (even
though it isn't really "code" we want to include, just comments).

Including these comments in the codebehind is not preferred because
the changes are specific to the ASPX page. Our site has multiple
versions of a given aspx for each language, ie

/en/mypage.aspx
/de/mypage.aspx
etc.

and the codebehind is stored in

/common/mypage.aspx.cs

Any help appreciated, thanks...

Aug 14 '07 #1
2 5179
Hi,

<%--
Everything here is a comment
--%>

So basically in <%-- --%>

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

<ma**************@gmail.comwrote in message
news:11**********************@o61g2000hsh.googlegr oups.com...
In .NET 2.0, is there any way to include comments in the aspx file
that do not get rendered to the client (ie no <!-- -->) ?

When I try to include C# comments in a code block in an aspx page,
like this:

<%
// ************************************************** *****
// CHANGE HISTORY:
// DATE USER CHANGE
// 08/14/2007 Tue ebloom updated logo
// ************************************************** *****
%>

I am getting an error

The Controls collection cannot be modified because the control
contains code blocks (i.e. <% ... %>).

It would seem this is because .NET doesn't like inline code (even
though it isn't really "code" we want to include, just comments).

Including these comments in the codebehind is not preferred because
the changes are specific to the ASPX page. Our site has multiple
versions of a given aspx for each language, ie

/en/mypage.aspx
/de/mypage.aspx
etc.

and the codebehind is stored in

/common/mypage.aspx.cs

Any help appreciated, thanks...

Aug 14 '07 #2
Aha - thanks!

PS I found more info on that here:

Tip/Trick: Using Server Side Comments with ASP.NET 2.0
http://weblogs.asp.net/scottgu/archi....NET-2.0-.aspx
On Aug 14, 2:48 pm, "Teemu Keiski" <jot...@aspalliance.comwrote:
Hi,

<%--
Everything here is a comment
--%>

So basically in <%-- --%>

--
Teemu Keiski
AspInsider, ASP.NET MVPhttp://blogs.aspadvice.com/jotekehttp://teemukeiski.net

<mad.scientist...@gmail.comwrote in message

news:11**********************@o61g2000hsh.googlegr oups.com...
In .NET 2.0, is there any way to include comments in the aspx file
that do not get rendered to the client (ie no <!-- -->) ?
When I try to include C# comments in a code block in an aspx page,
like this:
<%
// ************************************************** *****
// CHANGE HISTORY:
// DATE USER CHANGE
// 08/14/2007 Tue ebloom updated logo
// ************************************************** *****
%>
I am getting an error
The Controls collection cannot be modified because the control
contains code blocks (i.e. <% ... %>).
It would seem this is because .NET doesn't like inline code (even
though it isn't really "code" we want to include, just comments).
Including these comments in the codebehind is not preferred because
the changes are specific to the ASPX page. Our site has multiple
versions of a given aspx for each language, ie
/en/mypage.aspx
/de/mypage.aspx
etc.
and the codebehind is stored in
/common/mypage.aspx.cs
Any help appreciated, thanks...

Aug 14 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Luboą ©lapák | last post: by
29 posts views Thread by John Rivers | last post: by
6 posts views Thread by John Rivers | last post: by
2 posts views Thread by Will Rickards | last post: by
24 posts views Thread by John Rivers | last post: by
2 posts views Thread by rn5a | last post: by
5 posts views Thread by =?Utf-8?B?SmltbWVy?= | last post: by
1 post views Thread by UniDue | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.