Calling code-behind from javascript

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

    Calling code-behind from javascript

    Hi Frnds,

    Say I have vb code like this:

    Public Sub ll()
    MsgBox("heLOOOO OOOOOOOOOOOOOOO OOOOOOOOOO", MsgBoxStyle.OkO nly)
    End Sub

    The following script runs as soon as the page loads, no matter what
    the value of b is. why is it so ?

    <script type="text/javascript" language="javas cript">
    function ss()
    {
    var b = 1;
    if(b==2)
    {
    <% ll() %>;
    }
    }
    </script>

    I want the code to get executed only if the if-condition is true and
    also only when i call the script - i mean not as soon as the page
    loads. Please help me.

    Thanks,
    Nams here
  • David Mark

    #2
    Re: Calling code-behind from javascript

    On Feb 26, 4:57 am, nams <namsSof...@gma il.comwrote:
    Hi Frnds,
    >
    Say I have vb code like this:
    >
     Public Sub ll()
            MsgBox("heLOOOO OOOOOOOOOOOOOOO OOOOOOOOOO", MsgBoxStyle.OkO nly)
        End Sub
    This is not a VB.NET group. But as I am somewhat familiar with .NET,
    I can tell you that you are very confused (not an uncommon state
    among .NET developers.)

    Try searching for a VB.NET group.

    [snip]

    Comment

    • Evertjan.

      #3
      Re: Calling code-behind from javascript

      nams wrote on 26 feb 2008 in comp.lang.javas cript:
      Hi Frnds,
      >
      Say I have vb code like this:
      >
      Public Sub ll()
      MsgBox("heLOOOO OOOOOOOOOOOOOOO OOOOOOOOOO", MsgBoxStyle.OkO nly)
      End Sub
      >
      The following script runs as soon as the page loads, no matter what
      the value of b is. why is it so ?
      VB does not run on a server, nor on a browser,
      vb is a compiling language.

      VBscript can run on a server under ASP,
      or on an IE browser on the client.

      You seam to mean this to be serverside vbs code, as you show the <% %>
      below.

      Calling MsgBox() on a server in ASP-vbs is futile, as many servers do not
      evn have a screen, and ASP has no rights displaying on the server, and if
      you have 20 or 1000 concurrent users, whose MsgBox would it be that
      should be displayed on the server's possibly absent dislay?

      <script type="text/javascript" language="javas cript">
      language="javas cript" can be left out.
      function ss()
      {
      var b = 1;
      if(b==2)
      {
      <% ll() %>;
      When the clientside code is executed on the browser, the server is
      already finished with it.

      Only any resulting text stream is inserted for the browser to be executed
      ON THE CLIENT. Your serverside sub does NOT produce any clientside code.
      }
      }
      </script>
      >
      I want the code to get executed only if the if-condition is true and
      The if condition in your code above is never true.
      also only when i call the script - i mean not as soon as the page
      loads. Please help me.
      You can call a NEW serverside page from the client/browser by using the
      Ajax technique, but even then displaying a MsgBox on the server display
      seems not usefull and is impossible.
      Thanks,
      Nams here
      Please rethink the difference between serverside script execution and
      clientside script execution.


      --
      Evertjan.
      The Netherlands.
      (Please change the x'es to dots in my emailaddress)

      Comment

      Working...