In an ASP file, can Java Script code lines appear within a <% %> block? I can only find VB examples. Testing attemps to use Java Script there kill the application, resulting in a server error message.
If permitted, how can writing to a page be accomplished?
you can use <script type="text/jscript" runat="server">, but to use <%, you have to set the page languge to jscript. that can be done in the ASP config, or by using the <%@ language="jscript" %> directive first thing in a single file.
Yes, I had already gone the route of <%@ language="jscript" %>, but with no success for at least some JS statements that worked under "<script> </script>".
Please see the post "document.write". Some JS statments do not kill the server, but I cannot tell whether they are even working because I cannot reply back to the current web page, and its not like I can put "breakpoints" in the code like good old C++.
Placing "<script> </script>" within the <% %> also seems to be a No-No.
A couple of example JS code lines, indicating acceptable JS within "<% %>" would be helpful.
<body>
<%
function F()
{
var a = 0;
var b = 1;
var x;
x = b/a; // No error generated; thus, not being executed.
return x;
}
var z = F();
// All of these cause the server to return an error page.
//alert("z = " & z);
//response.write("z = " & z);
//document.write("<p style='color:#0000ff'>This text is styled with the style attribute!</p>");
%>
</body>
</html>
Bookmarks