I found some old code which I’m not sure I understand completely. The folowing is an .aspx page containing only JavaScript:
<%@ Page Language="C#" EnableSessionState="True" CodePage="65001" uiculture="auto" %>
<%
Response.ContentType = "text/plain";
%>
var csBackgroundColor;
function testfx() {
csBackgroundColor.setAttribute('disabled', 'disabled');
}
and it was referenced like this:
<script type="text/javascript" src="filename.js.aspx"></script>
I’m wondering why it wasn’t just marked as completely a JavaScript file? Was it done this way so you could include code blocks? With the file this way, I don’t even get IntelliSense.
<hack>To get intellisense you could wrap the code in<script> ... </script>blocks and remove them before saving.</hack>This was probably created by a developer that didn’t want to, couldn’t, or didn’t have the time to write object oriented JavaScript. Encapsulating the logic and configuring through a configuration object would allow you to de-couple the code from external variable dependencies, (e.g.
var foo = <%= SomeServerSideVariable %>).