473,804 Members | 4,005 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5389
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.comwro te in message
news:11******** **************@ o61g2000hsh.goo glegroups.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...@aspalli ance.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.comwro te in message

news:11******** **************@ o61g2000hsh.goo glegroups.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2679
by: lawrence | last post by:
2 Questions: 1.) Can anyone think of a way to speed up this function? It is terribly slow. I plan to reduce the number of directories to 3, which I guess will speed it up in the end. 2.) This seems to be the brute force method, and I'm wondering if anyone can think of a better strategy. I've been asked to make life easy on graphic designers by not making assumptions about where I might find the files that the software might need to...
1
1700
by: Lubo¹ ©lapák | last post by:
Hi, How can I invoke new render of aspx page from C# code. Thanks Lubos
29
3683
by: John Rivers | last post by:
Hello, What good reason there is for not allowing methods in ASPX pages I can't imagine, but here is how to get around that limitation: (START) <body MS_POSITIONING="FlowLayout"> <form id="Form1" method="post" runat="server"> <%
6
1838
by: John Rivers | last post by:
hi, here is how to do it and restore sanity to aspx html rendering: (please only reply with sensible architectural discussion - juan) put this at the end of an aspx file (or use an include at the end if you want to reuse it on many aspx pages) (notice closing brace) (start) <%}
2
2162
by: Will Rickards | last post by:
In my web application there is an interactive report. Then there need to be a printable version a pdf. So I found this java tool csstoxslfo and the java fop tool from apache that will take my xhtml and css and convert it to pdf. Problem 1) I designed the aspx page to produce the xhtml as output. So how do I save that rendered page to a file on the server? I think it involves overriding the Render method. I wrote some code which...
24
2764
by: John Rivers | last post by:
ASPX which means ASPX pages, the code-behind concept, User Controls, Web Controls etc. is very poorly designed and makes it extremely hard to develop professional quality web applications. ASPX is Microsoft's attempt to "dumb down" web application development to help unskilled developers such as web design agencies achieve some results. For high quality applications IHttpHandlers are the way to go.
2
2581
by: rn5a | last post by:
I have created the following WebService named NConnect.asmx using which I want an ASPX page to first authenticate a user & after successful user validation, the ASPX page should display a few TextBoxes for users to enter some data in those TextBoxes which will finally be inserted in a SQL Server 2005 DB table: <%@ WebService Language="VB" Class="NConnect" %> Imports System Imports System.Data
13
3568
by: Bob Jones | last post by:
Here is my situation: I have an aspx file stored in a resource file. All of the C# code is written inline via <script runat="server"tags. Let's call this page B. I also have page A that contains some javascript code that calls window.open. I pass the resource url of page B to Page A's window.open call. Page B is then loaded and executed but none of the server-side code is rendered. If I view the source of the page, the code (and page...
5
4136
by: =?Utf-8?B?SmltbWVy?= | last post by:
Hello, I've been trying to create a WCF SOAP Router Service that can forward not just the message body but also any security headers set by the originator of the message. The destination service I'm routing messages to uses WSHttpBinding, SSL with UserName/Password client credentials. Using guidance from the Technology samples I can create a router that forwards messages without security credentils but not with them. Can anybody point me...
0
10575
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10319
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7616
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6851
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5520
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4297
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3816
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.