473,493 Members | 3,174 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Would It be a bug of ASPNET?

When using "//" to comment the server side code in a web page, I found that
aspnet would only comment the first line of the gernerated code of result
page,
and that might produces an error when the gernerated code is multi-line,
because
the rest lines wouldn't be commented at all!
Nov 19 '05 #1
6 1137
Looks like you are using // to comment "generated" code ? Can you show us
what you do ? IMO // is for your own code.
Patrice

--

"David Zhu" <Da******@discussions.microsoft.com> a écrit dans le message de
news:C9**********************************@microsof t.com...
When using "//" to comment the server side code in a web page, I found that aspnet would only comment the first line of the gernerated code of result
page,
and that might produces an error when the gernerated code is multi-line,
because
the rest lines wouldn't be commented at all!

Nov 19 '05 #2
David Zhu wrote:
When using "//" to comment the server side code in a web page, I
found that aspnet would only comment the first line of the gernerated
code of result page,
and that might produces an error when the gernerated code is
multi-line, because
the rest lines wouldn't be commented at all!


Not a bug, but standard behaviour. If you want to comment out
multiple lines, then *you* should do it. Hint: select the code you want
to comment out, and hit ctrl+K, ctrl+C (to reverse, select the block
and use ctrl+K, ctrl+U).

If VS.Net would automatically comment out the whole expression, then
everyone would complain that it is not possible to comment out just
a part.
Hans Kesting
Nov 19 '05 #3
You may not understand my meaning.

The problem appear under the situation, likes below:

for example, I have a function of my user control "toolbar" to return a
javascript string, that's in code behind:

public string SetButtonVisibility(string btnName, bool visible)
{
string sResult = "";
sResult = "var btnObject;\r\n"+
"var e = document.all."+this.fID+".getElementsByTagName('SP AN');\r\n"+

}


"Hans Kesting" wrote:
David Zhu wrote:
When using "//" to comment the server side code in a web page, I
found that aspnet would only comment the first line of the gernerated
code of result page,
and that might produces an error when the gernerated code is
multi-line, because
the rest lines wouldn't be commented at all!


Not a bug, but standard behaviour. If you want to comment out
multiple lines, then *you* should do it. Hint: select the code you want
to comment out, and hit ctrl+K, ctrl+C (to reverse, select the block
and use ctrl+K, ctrl+U).

If VS.Net would automatically comment out the whole expression, then
everyone would complain that it is not possible to comment out just
a part.
Hans Kesting

Nov 19 '05 #4
No, you might not totally understand my meaning.

The problem may occur under such situation, like below:

for example, I have a function of a tool bar control (an user control),
that's in my
code behind file, I used it to generate several lines of javascripts:

public string SetButtonVisibility(string btnName, bool visible)
{
string sResult = "";
sResult = "var e =
document.all."+this.fID+".getElementsByTagName('SP AN');\r\n"
+ "if (e) { e.style.display = "+visible.ToString().ToLower()
+"?'inline':'none';}\r\n";
}

then, I want to use this function in page AA.aspx within a javascript segment:

<script language="javascript">
<%= Toolbar.SetButtonVisibility(Toolbar.BtnEditName, true) %>
</script>

That's fine, and as a result, that server side code would generate two lines:

<script language="javascript">
var e = document.all.Toolbar.getElementsByTagName('SPAN');
if (e) { e.style.display = true?'inline':'none';}
</script>

But, the problem would occur if I want to comment that server side code
using "//":
<script language="javascript">
//<%= Toolbar.SetButtonVisibility(Toolbar.BtnEditName, true) %>
</script>

Then, the result would be unexpected, like this:

<script language="javascript">
//var e = document.all.Toolbar.getElementsByTagName('SPAN');
if (e) { e.style.display = true?'inline':'none';}
</script>

So, an erorr would occur, is that a bug?

"Hans Kesting" wrote:
David Zhu wrote:
When using "//" to comment the server side code in a web page, I
found that aspnet would only comment the first line of the gernerated
code of result page,
and that might produces an error when the gernerated code is
multi-line, because
the rest lines wouldn't be commented at all!


Not a bug, but standard behaviour. If you want to comment out
multiple lines, then *you* should do it. Hint: select the code you want
to comment out, and hit ctrl+K, ctrl+C (to reverse, select the block
and use ctrl+K, ctrl+U).

If VS.Net would automatically comment out the whole expression, then
everyone would complain that it is not possible to comment out just
a part.
Hans Kesting

Nov 19 '05 #5
David Zhu wrote:
No, you might not totally understand my meaning.

The problem may occur under such situation, like below:

for example, I have a function of a tool bar control (an user
control), that's in my
code behind file, I used it to generate several lines of javascripts:

public string SetButtonVisibility(string btnName, bool visible)
{
string sResult = "";
sResult = "var e =
document.all."+this.fID+".getElementsByTagName('SP AN');\r\n"
+ "if (e) { e.style.display =
"+visible.ToString().ToLower()
+"?'inline':'none';}\r\n"; }

then, I want to use this function in page AA.aspx within a javascript
segment:

<script language="javascript">
<%= Toolbar.SetButtonVisibility(Toolbar.BtnEditName, true) %>
</script>

That's fine, and as a result, that server side code would generate
two lines:

<script language="javascript">
var e = document.all.Toolbar.getElementsByTagName('SPAN');
if (e) { e.style.display = true?'inline':'none';}
</script>

But, the problem would occur if I want to comment that server side
code
using "//":
<script language="javascript">
//<%= Toolbar.SetButtonVisibility(Toolbar.BtnEditName, true) %>
</script>

Then, the result would be unexpected, like this:

<script language="javascript">
//var e = document.all.Toolbar.getElementsByTagName('SPAN');
if (e) { e.style.display = true?'inline':'none';}
</script>

So, an erorr would occur, is that a bug?


OK, that is different from what I understood, but I still would not call this a bug.

The "//" here is not a signal to the ASP.Net system to treat everything after that as
a comment, but just two characters to send to the browser. Then you supply
some lines of code that also get sent to the browser. ASP.Net should *not* make
a guess about what you might mean.
The browser then parses the javascript block, sees that the first line is preceded
by "//" and treats it as a comment. Any other lines are used.

If you don't want this code to execute, you should use some other way to deactivate it.
You could change it into server-side comments:
<%--= Toolbar.SetButtonVisibility(Toolbar.BtnEditName, true) --%>
that way it will not execute at all.

Hans Kesting
Nov 19 '05 #6
Thanks a lot!

"Hans Kesting" wrote:
David Zhu wrote:
No, you might not totally understand my meaning.

The problem may occur under such situation, like below:

for example, I have a function of a tool bar control (an user
control), that's in my
code behind file, I used it to generate several lines of javascripts:

public string SetButtonVisibility(string btnName, bool visible)
{
string sResult = "";
sResult = "var e =
document.all."+this.fID+".getElementsByTagName('SP AN');\r\n"
+ "if (e) { e.style.display =
"+visible.ToString().ToLower()
+"?'inline':'none';}\r\n"; }

then, I want to use this function in page AA.aspx within a javascript
segment:

<script language="javascript">
<%= Toolbar.SetButtonVisibility(Toolbar.BtnEditName, true) %>
</script>

That's fine, and as a result, that server side code would generate
two lines:

<script language="javascript">
var e = document.all.Toolbar.getElementsByTagName('SPAN');
if (e) { e.style.display = true?'inline':'none';}
</script>

But, the problem would occur if I want to comment that server side
code
using "//":
<script language="javascript">
//<%= Toolbar.SetButtonVisibility(Toolbar.BtnEditName, true) %>
</script>

Then, the result would be unexpected, like this:

<script language="javascript">
//var e = document.all.Toolbar.getElementsByTagName('SPAN');
if (e) { e.style.display = true?'inline':'none';}
</script>

So, an erorr would occur, is that a bug?


OK, that is different from what I understood, but I still would not call this a bug.

The "//" here is not a signal to the ASP.Net system to treat everything after that as
a comment, but just two characters to send to the browser. Then you supply
some lines of code that also get sent to the browser. ASP.Net should *not* make
a guess about what you might mean.
The browser then parses the javascript block, sees that the first line is preceded
by "//" and treats it as a comment. Any other lines are used.

If you don't want this code to execute, you should use some other way to deactivate it.
You could change it into server-side comments:
<%--= Toolbar.SetButtonVisibility(Toolbar.BtnEditName, true) --%>
that way it will not execute at all.

Hans Kesting

Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
8207
by: Andrew J Fortune | last post by:
Hello all, I am trying to ascertain the difference, in terms of access and privileges, between the Internet Guest User Account (IUSR_machinename, where machinename is the name of your computer)...
6
1946
by: Matthew Wieder | last post by:
I have an ASPNET app that is running as the ASPNET machine user. It makes a call to the API CreateProcessWithLogonW. On Windows XP it executes without a problem, but on Windows 2000, I get an...
4
1623
by: Keith | last post by:
I have a small ASP.NET app that someone designed which I need to run on our server. The server is Windows 2000 Server and has the .NET Framework installed. How can I give ASP.NET permission to...
1
1175
by: homer | last post by:
Hello, everybody, When I try to create an ASP.NET 1.1 Application, I got: VS.Net has detected that the Specified Web Server Is Not Running ASP.NET Version 1.1" Error Message. I am running...
3
2392
by: Kim | last post by:
After installing MSDE2000 on my WIN XP machine, I created the database from Access using the upsizing wizard. Although the tables can be seen from the server explorer, I keep on encountering...
6
2416
by: Andrew Chalk | last post by:
My application attempts to connect to an SQL Server database as name ASPNET and Login Name SERVERNAME/ASPNET in response to these commands: SqlConnection myConnection = new SqlConnection("Data...
3
13058
by: musosdev | last post by:
Hi guys I've just noticed I don't have an ASPNET user account running on either my Workstation or Server (both running .net2.0, workstation has vs2005 pro). Simple question... should it be...
5
1778
by: Paul Aspinall | last post by:
Hi I am trying to print, server side, from my web application. I'm getting problems, as my ASPNET account is a local account, and is not trusted on the domain to print to printers (ie. does not...
1
1228
by: Jacky Zheng | last post by:
I installed aspnet 1.0 and aspnet 2.0 in my computer. when i deploy my webSite writed with aspnet2.0 to iis ,but is must change it from 1.0 to 2.0 in iis property settings by manual
5
1607
by: =?Utf-8?B?TWljaGFlbCBNaWxsZXI=?= | last post by:
I created a walkthrough and couldn't connect to my sql server. I looked up the problem and MSDN told me to create an ASPNET "User" in SQL Svr. It worked, but is that right? Do I have to do that...
0
7119
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6989
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7157
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,...
0
7367
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5453
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4889
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...
0
4579
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...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
285
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.