07-24-2023, 12:35 AM
I can't find a way to pass a variable declared in my code-behind aspx.js file to the corresponding code-behind.aspx markup file. The error I keep getting is this:
Parser Error Message: Code blocks are not allowed in this file.
My Code-Behind.aspx.js looks like this:
import System;
package Test {
class CodeBehind extends System.Web.UI.Page {
public var my_var;
public function Page_Load(sender, E:System.EventArgs) {
my_var = "This is my_var.";
}
}
}
I compile the code-behind file manually like this:
> jsc.exe /t:library /out:bin\codebehind.dll codebehind.aspx.js
The Code-Behind.aspx looks like this:
<%@ Page Language="JScript" Inherits="Test.CodeBehind" CompilationMode="Never" %>
<HTML>
<HEAD>
<TITLE>Hello World Test</TITLE>
</HEAD>
<BODY STYLE="font-size:12;font-family:arial,verdana,sans-serif;">
<FORM RUNAT="server">
<%= my_var %>
</FORM>
</BODY>
</HTML>
I know there are ASP.NET server controls such as asp:label and all that stuff but all I want is print out the contents of simple variables which serve as placeholders.
I don't want the website to compile everytime it is requested and I would like to keep the CompilationMode option set to "Never" and compile all code manually if possible.
Thanks!
Parser Error Message: Code blocks are not allowed in this file.
My Code-Behind.aspx.js looks like this:
import System;
package Test {
class CodeBehind extends System.Web.UI.Page {
public var my_var;
public function Page_Load(sender, E:System.EventArgs) {
my_var = "This is my_var.";
}
}
}
I compile the code-behind file manually like this:
> jsc.exe /t:library /out:bin\codebehind.dll codebehind.aspx.js
The Code-Behind.aspx looks like this:
<%@ Page Language="JScript" Inherits="Test.CodeBehind" CompilationMode="Never" %>
<HTML>
<HEAD>
<TITLE>Hello World Test</TITLE>
</HEAD>
<BODY STYLE="font-size:12;font-family:arial,verdana,sans-serif;">
<FORM RUNAT="server">
<%= my_var %>
</FORM>
</BODY>
</HTML>
I know there are ASP.NET server controls such as asp:label and all that stuff but all I want is print out the contents of simple variables which serve as placeholders.
I don't want the website to compile everytime it is requested and I would like to keep the CompilationMode option set to "Never" and compile all code manually if possible.
Thanks!