Variables' scope in ASPX ?

  • Thread starter Thread starter Lim siew Cheng
  • Start date Start date
L

Lim siew Cheng

Hi,

I'm trying to know why the below is not working....
<html>
<head>
<title>sample</title>

</head>
<%
int oo = 333 ;
%>

<body MS_POSITIONING="GridLayout">
<form id="sample" method="post" runat="server">
LALAL
<%=oo%>
</form>
</body>
</html>

CS0103: The name 'oo' does not exist in the class or namespace
'ASP.sample_aspx'

So this cannot be achieved?

REgards
LSc
 
I'd suggest defining oo as a public variable in your code behind.
It's more OO that way anyway. (Object Oriented)
;-)
 
right after the error message you can see "View Compiled Source"
And actually see how your ASPX was converted to C# and then compiled.

You should declare oo inside of the following.

<script runat="server">
int oo=333;
</script>



George.
 
Back
Top