Variables' scope in ASPX ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lim siew Cheng

    #1

    Variables' scope in ASPX ?

    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_asp x'

    So this cannot be achieved?

    REgards
    LSc

  • Steve C. Orr, MCSD

    #2
    Re: Variables' scope in ASPX ?

    I'd suggest defining oo as a public variable in your code behind.
    It's more OO that way anyway. (Object Oriented)
    ;-)

    --
    I hope this helps,
    Steve C. Orr, MCSD

    Hire top-notch developers at http://www.able-consulting.com



    "Lim siew Cheng" <siew_cheng555@ yahoo.com> wrote in message
    news:3f450709$1 @news.starhub.n et.sg...[color=blue]
    > 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_asp x'
    >
    > So this cannot be achieved?
    >
    > REgards
    > LSc
    >[/color]


    Comment

    • George Ter-Saakov

      #3
      Re: Variables' scope in ASPX ?

      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.


      "Lim siew Cheng" <siew_cheng555@ yahoo.com> wrote in message
      news:3f450709$1 @news.starhub.n et.sg...[color=blue]
      > 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_asp x'
      >
      > So this cannot be achieved?
      >
      > REgards
      > LSc
      >[/color]


      Comment

      Working...