Quote:
quote:The reason for this error has something to do with the javascript functions that the runtime adds to the page to enable postbacks and such, but I can not remember exactly why this problem occurs. In any event, this is the work around to that problem.
|
Actually, it has to do with the server side scripts, and only with pages without code behind (and with classic ASP pages).
With a page with in-line code or a classic ASP page, all server side code is wrapped in a <script> element like tis:
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
}
</script>
Now, imagine you had your script without the split end tag. You'd end up with this:
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
string
js = "<script type=\"text/javascript\">";
js += "alert('Something');";
js += "</script>";
Response.Write(
js);
}
</script>
With color coding on, you immediately see what's going on. All the code is black, except for the *first* </script> tag which is seen as the closing tag for the *server side script element*, and not as a part of a string literal.
Splitting up the end tag like Doug suggested fixes the problem. The first closing script tag is now seen as a string literal, while the second one is used to close the actual <script> element.
AFAIK, you only need this in pages with in-line code or in classic ASP pages. Pages with code behind don't suffer from this problem as there's no <script> element anywhere....
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of
ASP.NET 2.0 Instant Results and
Beginning Dreamweaver MX / MX 2004