Saturday, March 31, 2012

Strange and annoying problem

Even commenting a line in javascript still prompts for an error. If I remove the following line then no error, but again if i put it back, even commented error occurs.

//opener.document.getElementById('<%=TextBox1.ClientID%>').value='akberalikaka';

isn't it strange behavior

Yes it is strange. As far as i am aware of, there are three types of comment you can do in java:

1. Multiple-line :/* and*/

2.One-line comments of C++ style: Begins with // and continue up to the next line break:

3.One-line comments with theHTML comment-opening sequence (<!--). Note that the JavaScript interpreter ignores the closing characters of HTML comments (-->). Consider this example:
<!-- This is treated as a one-line JS comment<!-- It works just like a comment beginning with //<!-- --> This is also a one-line JS comment<!-- --> because JS ignores the closing characters<!-- --> of HTML-style comments

HTML-style comments are not usually found in the middle of JavaScript code. However, it is recommended to use HTML comments for hiding Javascript code from old browsers

Try using this mate


Hi,

//opener.document.getElementById('<%=TextBox1.ClientID%>').value='akberalikaka';

Your comment in javascript doesn't stop<%=TextBox1.ClientID%> since it is asp.net code. So to clear the error you have to remove this code.


You have to comment the aspnet code also

if you are using C#

//opener.document.getElementById('<%/*=TextBox1.ClientID*/%>').value='akberalikaka';

if you are using VB

//opener.document.getElementById('<%'=TextBox1.ClientID'%>').value='akberalikaka';

<%'=TextBox1.ClientID'%> is equivalent to <% Response.Write(TextBox1.ClientID) %>

0 comments:

Post a Comment