how to call aspx variable from Javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jade

    #1

    how to call aspx variable from Javascript

    I saw some web page saying I could do it this way in
    javascript:
    var iNumber = <%#publicvarnam e [or] publicpropertyn ame %>

    but it doesn't seem to work. I have this piece of code
    here in javascript:
    <script language="javas cript">
    var sessionServer = "<%#jsTestServe r%>";
    alert(sessionSe rver);
    </script>

    and the variable is defined in the C# code behind:
    public string jsTestServer
    = "\\\\TestServer \\TestSession\\ ";

    when I run it, alert has no message in it.
  • Chris R. Timmons

    #2
    Re: how to call aspx variable from Javascript

    "Jade" <anonymous@disc ussions.microso ft.com> wrote in
    news:12da01c3a8 79$499e82e0$a60 1280a@phx.gbl:
    [color=blue]
    > I saw some web page saying I could do it this way in
    > javascript:
    > var iNumber = <%#publicvarnam e [or] publicpropertyn ame %>
    >
    > but it doesn't seem to work. I have this piece of code
    > here in javascript:
    ><script language="javas cript">
    > var sessionServer = "<%#jsTestServe r%>";
    > alert(sessionSe rver);
    ></script>
    >
    > and the variable is defined in the C# code behind:
    > public string jsTestServer
    >= "\\\\TestServer \\TestSession\\ ";
    >
    > when I run it, alert has no message in it.[/color]

    Jade,

    Try <%= jsTestServer %> instead of <%# jsTestServer %>.


    Hope this helps.

    Chris.
    -------------
    C.R. Timmons Consulting, Inc.

    Comment

    • Michael Giagnocavo [MVP]

      #3
      Re: how to call aspx variable from Javascript

      <%# is the DataBinding syntax. You need to make sure you call DataBind() on
      your page (in the server code. You can also use <%=someVariable %>, which
      will print the value out when it runs. The DataBind way is a little more
      elegant, I feel.

      -mike
      MVP

      "Jade" <anonymous@disc ussions.microso ft.com> wrote in message
      news:12da01c3a8 79$499e82e0$a60 1280a@phx.gbl.. .[color=blue]
      > I saw some web page saying I could do it this way in
      > javascript:
      > var iNumber = <%#publicvarnam e [or] publicpropertyn ame %>
      >
      > but it doesn't seem to work. I have this piece of code
      > here in javascript:
      > <script language="javas cript">
      > var sessionServer = "<%#jsTestServe r%>";
      > alert(sessionSe rver);
      > </script>
      >
      > and the variable is defined in the C# code behind:
      > public string jsTestServer
      > = "\\\\TestServer \\TestSession\\ ";
      >
      > when I run it, alert has no message in it.[/color]


      Comment

      • Guest's Avatar

        #4
        Re: how to call aspx variable from Javascript

        It still doesn't work. Here is exactly what I have now:

        <script language="javas cript">
        var sessionServer = "<%=jsTestServe r%>";
        alert(sessionSe rver);

        function CreateSessionFl ag()
        {
        alert("hello");
        }

        function DeleteSessionFl ag()
        {
        alert("bye");
        }
        </script>
        </head>
        <body MS_POSITIONING= "GridLayout "
        onLoad="CreateS essionFlag();">

        In the C# code behind:
        public class WebForm1 : System.Web.UI.P age
        {
        public string jsTestServer
        = "\\\\ze483z\\Te stSession\\";

        private void Page_Load(objec t sender, System.EventArg s
        e)
        { // Put user code to initialize the page here }

        It's a very simple test program. After I changed to "<%
        =jsTestServer%> ", it generates some jscript error -
        object expected on the "onload" line. If I used the old
        way var sessionServer = "<%#jsTestServe r%>"; it pops up
        an alert with empty message.

        [color=blue]
        >-----Original Message-----
        ><%# is the DataBinding syntax. You need to make sure[/color]
        you call DataBind() on[color=blue]
        >your page (in the server code. You can also use <%[/color]
        =someVariable%> , which[color=blue]
        >will print the value out when it runs. The DataBind way[/color]
        is a little more[color=blue]
        >elegant, I feel.
        >
        >-mike
        >MVP
        >
        >"Jade" <anonymous@disc ussions.microso ft.com> wrote in[/color]
        message[color=blue]
        >news:12da01c3a 879$499e82e0$a6 01280a@phx.gbl. ..[color=green]
        >> I saw some web page saying I could do it this way in
        >> javascript:
        >> var iNumber = <%#publicvarnam e [or] publicpropertyn ame[/color][/color]
        %>[color=blue][color=green]
        >>
        >> but it doesn't seem to work. I have this piece of code
        >> here in javascript:
        >> <script language="javas cript">
        >> var sessionServer = "<%#jsTestServe r%>";
        >> alert(sessionSe rver);
        >> </script>
        >>
        >> and the variable is defined in the C# code behind:
        >> public string jsTestServer
        >> = "\\\\TestServer \\TestSession\\ ";
        >>
        >> when I run it, alert has no message in it.[/color]
        >
        >
        >.
        >[/color]

        Comment

        • Michael Giagnocavo [MVP]

          #5
          Re: how to call aspx variable from Javascript

          Check out HTML output. If you have \\ characters, they will get interpreted
          by C#. Try with your variable as "Hello, JScript!" :).

          Using the <%# syntax, did you do a this.DataBind() ; call in your OnLoad or
          somewhere?

          -mike
          MVP

          <anonymous@disc ussions.microso ft.com> wrote in message
          news:145601c3a8 80$ad16aad0$a50 1280a@phx.gbl.. .[color=blue]
          > It still doesn't work. Here is exactly what I have now:
          >
          > <script language="javas cript">
          > var sessionServer = "<%=jsTestServe r%>";
          > alert(sessionSe rver);
          >
          > function CreateSessionFl ag()
          > {
          > alert("hello");
          > }
          >
          > function DeleteSessionFl ag()
          > {
          > alert("bye");
          > }
          > </script>
          > </head>
          > <body MS_POSITIONING= "GridLayout "
          > onLoad="CreateS essionFlag();">
          >
          > In the C# code behind:
          > public class WebForm1 : System.Web.UI.P age
          > {
          > public string jsTestServer
          > = "\\\\ze483z\\Te stSession\\";
          >
          > private void Page_Load(objec t sender, System.EventArg s
          > e)
          > { // Put user code to initialize the page here }
          >
          > It's a very simple test program. After I changed to "<%
          > =jsTestServer%> ", it generates some jscript error -
          > object expected on the "onload" line. If I used the old
          > way var sessionServer = "<%#jsTestServe r%>"; it pops up
          > an alert with empty message.
          >
          >[color=green]
          > >-----Original Message-----
          > ><%# is the DataBinding syntax. You need to make sure[/color]
          > you call DataBind() on[color=green]
          > >your page (in the server code. You can also use <%[/color]
          > =someVariable%> , which[color=green]
          > >will print the value out when it runs. The DataBind way[/color]
          > is a little more[color=green]
          > >elegant, I feel.
          > >
          > >-mike
          > >MVP
          > >
          > >"Jade" <anonymous@disc ussions.microso ft.com> wrote in[/color]
          > message[color=green]
          > >news:12da01c3a 879$499e82e0$a6 01280a@phx.gbl. ..[color=darkred]
          > >> I saw some web page saying I could do it this way in
          > >> javascript:
          > >> var iNumber = <%#publicvarnam e [or] publicpropertyn ame[/color][/color]
          > %>[color=green][color=darkred]
          > >>
          > >> but it doesn't seem to work. I have this piece of code
          > >> here in javascript:
          > >> <script language="javas cript">
          > >> var sessionServer = "<%#jsTestServe r%>";
          > >> alert(sessionSe rver);
          > >> </script>
          > >>
          > >> and the variable is defined in the C# code behind:
          > >> public string jsTestServer
          > >> = "\\\\TestServer \\TestSession\\ ";
          > >>
          > >> when I run it, alert has no message in it.[/color]
          > >
          > >
          > >.
          > >[/color][/color]


          Comment

          • Jade

            #6
            Re: how to call aspx variable from Javascript

            It did interpreted correctly in HTML:
            var sessionServer = "\\ze483z\TestS ession\";

            where/how should I use "this.DataBind( );" exactly in
            Onload???

            [color=blue]
            >-----Original Message-----
            >Check out HTML output. If you have \\ characters, they[/color]
            will get interpreted[color=blue]
            >by C#. Try with your variable as "Hello, JScript!" :).
            >
            >Using the <%# syntax, did you do a this.DataBind() ; call[/color]
            in your OnLoad or[color=blue]
            >somewhere?
            >
            >-mike
            >MVP
            >
            ><anonymous@dis cussions.micros oft.com> wrote in message
            >news:145601c3a 880$ad16aad0$a5 01280a@phx.gbl. ..[color=green]
            >> It still doesn't work. Here is exactly what I have[/color][/color]
            now:[color=blue][color=green]
            >>
            >> <script language="javas cript">
            >> var sessionServer = "<%=jsTestServe r%>";
            >> alert(sessionSe rver);
            >>
            >> function CreateSessionFl ag()
            >> {
            >> alert("hello");
            >> }
            >>
            >> function DeleteSessionFl ag()
            >> {
            >> alert("bye");
            >> }
            >> </script>
            >> </head>
            >> <body MS_POSITIONING= "GridLayout "
            >> onLoad="CreateS essionFlag();">
            >>
            >> In the C# code behind:
            >> public class WebForm1 : System.Web.UI.P age
            >> {
            >> public string jsTestServer
            >> = "\\\\ze483z\\Te stSession\\";
            >>
            >> private void Page_Load(objec t sender,[/color][/color]
            System.EventArg s[color=blue][color=green]
            >> e)
            >> { // Put user code to initialize the page here }
            >>
            >> It's a very simple test program. After I changed[/color][/color]
            to "<%[color=blue][color=green]
            >> =jsTestServer%> ", it generates some jscript error -
            >> object expected on the "onload" line. If I used the[/color][/color]
            old[color=blue][color=green]
            >> way var sessionServer = "<%#jsTestServe r%>"; it pops up
            >> an alert with empty message.
            >>
            >>[color=darkred]
            >> >-----Original Message-----
            >> ><%# is the DataBinding syntax. You need to make sure[/color]
            >> you call DataBind() on[color=darkred]
            >> >your page (in the server code. You can also use <%[/color]
            >> =someVariable%> , which[color=darkred]
            >> >will print the value out when it runs. The DataBind[/color][/color][/color]
            way[color=blue][color=green]
            >> is a little more[color=darkred]
            >> >elegant, I feel.
            >> >
            >> >-mike
            >> >MVP
            >> >
            >> >"Jade" <anonymous@disc ussions.microso ft.com> wrote in[/color]
            >> message[color=darkred]
            >> >news:12da01c3a 879$499e82e0$a6 01280a@phx.gbl. ..
            >> >> I saw some web page saying I could do it this way in
            >> >> javascript:
            >> >> var iNumber = <%#publicvarnam e [or][/color][/color][/color]
            publicpropertyn ame[color=blue][color=green]
            >> %>[color=darkred]
            >> >>
            >> >> but it doesn't seem to work. I have this piece of[/color][/color][/color]
            code[color=blue][color=green][color=darkred]
            >> >> here in javascript:
            >> >> <script language="javas cript">
            >> >> var sessionServer = "<%#jsTestServe r%>";
            >> >> alert(sessionSe rver);
            >> >> </script>
            >> >>
            >> >> and the variable is defined in the C# code behind:
            >> >> public string jsTestServer
            >> >> = "\\\\TestServer \\TestSession\\ ";
            >> >>
            >> >> when I run it, alert has no message in it.
            >> >
            >> >
            >> >.
            >> >[/color][/color]
            >
            >
            >.
            >[/color]

            Comment

            • Michael Giagnocavo [MVP]

              #7
              Re: how to call aspx variable from Javascript

              > It did interpreted correctly in HTML:[color=blue]
              > var sessionServer = "\\ze483z\TestS ession\";[/color]

              Right, and that's not valid for JScript, thus the runtime error.
              [color=blue]
              > where/how should I use "this.DataBind( );" exactly in
              > Onload???[/color]

              this.DataBind() ; // That's it

              That binds all the <%# markers.

              -mike
              MVP

              [color=blue]
              >[color=green]
              > >-----Original Message-----
              > >Check out HTML output. If you have \\ characters, they[/color]
              > will get interpreted[color=green]
              > >by C#. Try with your variable as "Hello, JScript!" :).
              > >
              > >Using the <%# syntax, did you do a this.DataBind() ; call[/color]
              > in your OnLoad or[color=green]
              > >somewhere?
              > >
              > >-mike
              > >MVP
              > >
              > ><anonymous@dis cussions.micros oft.com> wrote in message
              > >news:145601c3a 880$ad16aad0$a5 01280a@phx.gbl. ..[color=darkred]
              > >> It still doesn't work. Here is exactly what I have[/color][/color]
              > now:[color=green][color=darkred]
              > >>
              > >> <script language="javas cript">
              > >> var sessionServer = "<%=jsTestServe r%>";
              > >> alert(sessionSe rver);
              > >>
              > >> function CreateSessionFl ag()
              > >> {
              > >> alert("hello");
              > >> }
              > >>
              > >> function DeleteSessionFl ag()
              > >> {
              > >> alert("bye");
              > >> }
              > >> </script>
              > >> </head>
              > >> <body MS_POSITIONING= "GridLayout "
              > >> onLoad="CreateS essionFlag();">
              > >>
              > >> In the C# code behind:
              > >> public class WebForm1 : System.Web.UI.P age
              > >> {
              > >> public string jsTestServer
              > >> = "\\\\ze483z\\Te stSession\\";
              > >>
              > >> private void Page_Load(objec t sender,[/color][/color]
              > System.EventArg s[color=green][color=darkred]
              > >> e)
              > >> { // Put user code to initialize the page here }
              > >>
              > >> It's a very simple test program. After I changed[/color][/color]
              > to "<%[color=green][color=darkred]
              > >> =jsTestServer%> ", it generates some jscript error -
              > >> object expected on the "onload" line. If I used the[/color][/color]
              > old[color=green][color=darkred]
              > >> way var sessionServer = "<%#jsTestServe r%>"; it pops up
              > >> an alert with empty message.
              > >>
              > >>
              > >> >-----Original Message-----
              > >> ><%# is the DataBinding syntax. You need to make sure
              > >> you call DataBind() on
              > >> >your page (in the server code. You can also use <%
              > >> =someVariable%> , which
              > >> >will print the value out when it runs. The DataBind[/color][/color]
              > way[color=green][color=darkred]
              > >> is a little more
              > >> >elegant, I feel.
              > >> >
              > >> >-mike
              > >> >MVP
              > >> >
              > >> >"Jade" <anonymous@disc ussions.microso ft.com> wrote in
              > >> message
              > >> >news:12da01c3a 879$499e82e0$a6 01280a@phx.gbl. ..
              > >> >> I saw some web page saying I could do it this way in
              > >> >> javascript:
              > >> >> var iNumber = <%#publicvarnam e [or][/color][/color]
              > publicpropertyn ame[color=green][color=darkred]
              > >> %>
              > >> >>
              > >> >> but it doesn't seem to work. I have this piece of[/color][/color]
              > code[color=green][color=darkred]
              > >> >> here in javascript:
              > >> >> <script language="javas cript">
              > >> >> var sessionServer = "<%#jsTestServe r%>";
              > >> >> alert(sessionSe rver);
              > >> >> </script>
              > >> >>
              > >> >> and the variable is defined in the C# code behind:
              > >> >> public string jsTestServer
              > >> >> = "\\\\TestServer \\TestSession\\ ";
              > >> >>
              > >> >> when I run it, alert has no message in it.
              > >> >
              > >> >
              > >> >.
              > >> >[/color]
              > >
              > >
              > >.
              > >[/color][/color]


              Comment

              • Jade

                #8
                Re: how to call aspx variable from Javascript

                I'm sorry, Mike. I still don't know where to
                put "this.DataBind( );" I put it in
                private void Page_Load(objec t sender, System.EventArg s e)
                {
                this.DataBind() ;
                }

                and I still have the runtime error.

                [color=blue]
                >-----Original Message-----[color=green]
                >> It did interpreted correctly in HTML:
                >> var sessionServer = "\\ze483z\TestS ession\";[/color]
                >
                >Right, and that's not valid for JScript, thus the[/color]
                runtime error.[color=blue]
                >[color=green]
                >> where/how should I use "this.DataBind( );" exactly in
                >> Onload???[/color]
                >
                >this.DataBind( ); // That's it
                >
                >That binds all the <%# markers.
                >
                >-mike
                >MVP
                >
                >[color=green]
                >>[color=darkred]
                >> >-----Original Message-----
                >> >Check out HTML output. If you have \\ characters,[/color][/color][/color]
                they[color=blue][color=green]
                >> will get interpreted[color=darkred]
                >> >by C#. Try with your variable as "Hello,[/color][/color][/color]
                JScript!" :).[color=blue][color=green][color=darkred]
                >> >
                >> >Using the <%# syntax, did you do a this.DataBind() ;[/color][/color][/color]
                call[color=blue][color=green]
                >> in your OnLoad or[color=darkred]
                >> >somewhere?
                >> >
                >> >-mike
                >> >MVP
                >> >
                >> ><anonymous@dis cussions.micros oft.com> wrote in message
                >> >news:145601c3a 880$ad16aad0$a5 01280a@phx.gbl. ..
                >> >> It still doesn't work. Here is exactly what I have[/color]
                >> now:[color=darkred]
                >> >>
                >> >> <script language="javas cript">
                >> >> var sessionServer = "<%=jsTestServe r%>";
                >> >> alert(sessionSe rver);
                >> >>
                >> >> function CreateSessionFl ag()
                >> >> {
                >> >> alert("hello");
                >> >> }
                >> >>
                >> >> function DeleteSessionFl ag()
                >> >> {
                >> >> alert("bye");
                >> >> }
                >> >> </script>
                >> >> </head>
                >> >> <body MS_POSITIONING= "GridLayout "
                >> >> onLoad="CreateS essionFlag();">
                >> >>
                >> >> In the C# code behind:
                >> >> public class WebForm1 : System.Web.UI.P age
                >> >> {
                >> >> public string jsTestServer
                >> >> = "\\\\ze483z\\Te stSession\\";
                >> >>
                >> >> private void Page_Load(objec t sender,[/color]
                >> System.EventArg s[color=darkred]
                >> >> e)
                >> >> { // Put user code to initialize the page here }
                >> >>
                >> >> It's a very simple test program. After I changed[/color]
                >> to "<%[color=darkred]
                >> >> =jsTestServer%> ", it generates some jscript error -
                >> >> object expected on the "onload" line. If I used the[/color]
                >> old[color=darkred]
                >> >> way var sessionServer = "<%#jsTestServe r%>"; it[/color][/color][/color]
                pops up[color=blue][color=green][color=darkred]
                >> >> an alert with empty message.
                >> >>
                >> >>
                >> >> >-----Original Message-----
                >> >> ><%# is the DataBinding syntax. You need to make[/color][/color][/color]
                sure[color=blue][color=green][color=darkred]
                >> >> you call DataBind() on
                >> >> >your page (in the server code. You can also use <%
                >> >> =someVariable%> , which
                >> >> >will print the value out when it runs. The[/color][/color][/color]
                DataBind[color=blue][color=green]
                >> way[color=darkred]
                >> >> is a little more
                >> >> >elegant, I feel.
                >> >> >
                >> >> >-mike
                >> >> >MVP
                >> >> >
                >> >> >"Jade" <anonymous@disc ussions.microso ft.com> wrote[/color][/color][/color]
                in[color=blue][color=green][color=darkred]
                >> >> message
                >> >> >news:12da01c3a 879$499e82e0$a6 01280a@phx.gbl. ..
                >> >> >> I saw some web page saying I could do it this[/color][/color][/color]
                way in[color=blue][color=green][color=darkred]
                >> >> >> javascript:
                >> >> >> var iNumber = <%#publicvarnam e [or][/color]
                >> publicpropertyn ame[color=darkred]
                >> >> %>
                >> >> >>
                >> >> >> but it doesn't seem to work. I have this piece[/color][/color][/color]
                of[color=blue][color=green]
                >> code[color=darkred]
                >> >> >> here in javascript:
                >> >> >> <script language="javas cript">
                >> >> >> var sessionServer = "<%#jsTestServe r%>";
                >> >> >> alert(sessionSe rver);
                >> >> >> </script>
                >> >> >>
                >> >> >> and the variable is defined in the C# code[/color][/color][/color]
                behind:[color=blue][color=green][color=darkred]
                >> >> >> public string jsTestServer
                >> >> >> = "\\\\TestServer \\TestSession\\ ";
                >> >> >>
                >> >> >> when I run it, alert has no message in it.
                >> >> >
                >> >> >
                >> >> >.
                >> >> >
                >> >
                >> >
                >> >.
                >> >[/color][/color]
                >
                >
                >.
                >[/color]

                Comment

                • Michael Giagnocavo [MVP]

                  #9
                  Re: how to call aspx variable from Javascript

                  The runtime error is from JScript most likely.

                  var sessionServer = "\\ze483z\TestS ession\"; is not a valid string literal.

                  -mike
                  MVP

                  "Jade" <anonymous@disc ussions.microso ft.com> wrote in message
                  news:034201c3a8 97$f3022d00$a40 1280a@phx.gbl.. .[color=blue]
                  > I'm sorry, Mike. I still don't know where to
                  > put "this.DataBind( );" I put it in
                  > private void Page_Load(objec t sender, System.EventArg s e)
                  > {
                  > this.DataBind() ;
                  > }
                  >
                  > and I still have the runtime error.
                  >
                  >[color=green]
                  > >-----Original Message-----[color=darkred]
                  > >> It did interpreted correctly in HTML:
                  > >> var sessionServer = "\\ze483z\TestS ession\";[/color]
                  > >
                  > >Right, and that's not valid for JScript, thus the[/color]
                  > runtime error.[color=green]
                  > >[color=darkred]
                  > >> where/how should I use "this.DataBind( );" exactly in
                  > >> Onload???[/color]
                  > >
                  > >this.DataBind( ); // That's it
                  > >
                  > >That binds all the <%# markers.
                  > >
                  > >-mike
                  > >MVP
                  > >
                  > >[color=darkred]
                  > >>
                  > >> >-----Original Message-----
                  > >> >Check out HTML output. If you have \\ characters,[/color][/color]
                  > they[color=green][color=darkred]
                  > >> will get interpreted
                  > >> >by C#. Try with your variable as "Hello,[/color][/color]
                  > JScript!" :).[color=green][color=darkred]
                  > >> >
                  > >> >Using the <%# syntax, did you do a this.DataBind() ;[/color][/color]
                  > call[color=green][color=darkred]
                  > >> in your OnLoad or
                  > >> >somewhere?
                  > >> >
                  > >> >-mike
                  > >> >MVP
                  > >> >
                  > >> ><anonymous@dis cussions.micros oft.com> wrote in message
                  > >> >news:145601c3a 880$ad16aad0$a5 01280a@phx.gbl. ..
                  > >> >> It still doesn't work. Here is exactly what I have
                  > >> now:
                  > >> >>
                  > >> >> <script language="javas cript">
                  > >> >> var sessionServer = "<%=jsTestServe r%>";
                  > >> >> alert(sessionSe rver);
                  > >> >>
                  > >> >> function CreateSessionFl ag()
                  > >> >> {
                  > >> >> alert("hello");
                  > >> >> }
                  > >> >>
                  > >> >> function DeleteSessionFl ag()
                  > >> >> {
                  > >> >> alert("bye");
                  > >> >> }
                  > >> >> </script>
                  > >> >> </head>
                  > >> >> <body MS_POSITIONING= "GridLayout "
                  > >> >> onLoad="CreateS essionFlag();">
                  > >> >>
                  > >> >> In the C# code behind:
                  > >> >> public class WebForm1 : System.Web.UI.P age
                  > >> >> {
                  > >> >> public string jsTestServer
                  > >> >> = "\\\\ze483z\\Te stSession\\";
                  > >> >>
                  > >> >> private void Page_Load(objec t sender,
                  > >> System.EventArg s
                  > >> >> e)
                  > >> >> { // Put user code to initialize the page here }
                  > >> >>
                  > >> >> It's a very simple test program. After I changed
                  > >> to "<%
                  > >> >> =jsTestServer%> ", it generates some jscript error -
                  > >> >> object expected on the "onload" line. If I used the
                  > >> old
                  > >> >> way var sessionServer = "<%#jsTestServe r%>"; it[/color][/color]
                  > pops up[color=green][color=darkred]
                  > >> >> an alert with empty message.
                  > >> >>
                  > >> >>
                  > >> >> >-----Original Message-----
                  > >> >> ><%# is the DataBinding syntax. You need to make[/color][/color]
                  > sure[color=green][color=darkred]
                  > >> >> you call DataBind() on
                  > >> >> >your page (in the server code. You can also use <%
                  > >> >> =someVariable%> , which
                  > >> >> >will print the value out when it runs. The[/color][/color]
                  > DataBind[color=green][color=darkred]
                  > >> way
                  > >> >> is a little more
                  > >> >> >elegant, I feel.
                  > >> >> >
                  > >> >> >-mike
                  > >> >> >MVP
                  > >> >> >
                  > >> >> >"Jade" <anonymous@disc ussions.microso ft.com> wrote[/color][/color]
                  > in[color=green][color=darkred]
                  > >> >> message
                  > >> >> >news:12da01c3a 879$499e82e0$a6 01280a@phx.gbl. ..
                  > >> >> >> I saw some web page saying I could do it this[/color][/color]
                  > way in[color=green][color=darkred]
                  > >> >> >> javascript:
                  > >> >> >> var iNumber = <%#publicvarnam e [or]
                  > >> publicpropertyn ame
                  > >> >> %>
                  > >> >> >>
                  > >> >> >> but it doesn't seem to work. I have this piece[/color][/color]
                  > of[color=green][color=darkred]
                  > >> code
                  > >> >> >> here in javascript:
                  > >> >> >> <script language="javas cript">
                  > >> >> >> var sessionServer = "<%#jsTestServe r%>";
                  > >> >> >> alert(sessionSe rver);
                  > >> >> >> </script>
                  > >> >> >>
                  > >> >> >> and the variable is defined in the C# code[/color][/color]
                  > behind:[color=green][color=darkred]
                  > >> >> >> public string jsTestServer
                  > >> >> >> = "\\\\TestServer \\TestSession\\ ";
                  > >> >> >>
                  > >> >> >> when I run it, alert has no message in it.
                  > >> >> >
                  > >> >> >
                  > >> >> >.
                  > >> >> >
                  > >> >
                  > >> >
                  > >> >.
                  > >> >[/color]
                  > >
                  > >
                  > >.
                  > >[/color][/color]


                  Comment

                  Working...