ASP/VBS and Javascript

Discussion in 'ASP General' started by Excel User, Sep 24, 2009.

  1. Excel User

    Excel User Guest

    Hi,

    Just wanted some advice, I have an asp page that has a script that creates
    some values i.e.

    <%
    somevalue = "aaa"
    somevalue2 = "bbb"

    %>

    also on the page I include some js scripts as:

    <script type="text/javascript" src="sources.js"></script>

    within the js scripts I would like to use some of vb values, but the js
    throws an error, what is the best approach to use the values but keep the JS
    external?

    Thanks
    Excel User, Sep 24, 2009
    #1
    1. Advertising

  2. Excel User

    Evertjan. Guest

    Excel User wrote on 24 sep 2009 in
    microsoft.public.inetserver.asp.general:

    > Just wanted some advice, I have an asp page that has a script that
    > creates some values i.e.
    >
    > <%
    > somevalue = "aaa"
    > somevalue2 = "bbb"
    >
    > %>
    >
    > also on the page I include some js scripts as:
    >
    > <script type="text/javascript" src="sources.js"></script>
    >
    > within the js scripts I would like to use some of vb values,


    You probably mean the values of vb variables?

    You probably mean VBS variables, as ASP does not platform VB.

    They are just serverside variables,
    it does not matter if they are made by ASP/vbscript or by ASP/Jscript.

    "VD variables" could even be "clientdside variables" in IE.

    > but the js throws an error,


    Because surely you made a coding error. Without showing the essential
    code, the error throwing is irrelevant to your Q.

    > what is the best approach to use the values but
    > keep the JS external?


    That is a bad idea.
    Why would you ever want that?

    An external js file is ment to be cached clientside,
    so the imported values of serverside variables will not be actual.

    Better have essential calls to the external file on the actual page, like

    <script type="text/javascript" src="sources.js">
    </script>
    <script type='text/javascript'>
    dostuff('<%= myASPvalue %>');
    </script>

    where the function is defined in the external script.

    =========================

    However you COULD rename the .js to .asp
    and add session variables to the external script,
    but the caching problem remails,
    and the sense remains non.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Sep 24, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brad

    Running a VBS file from ASP.NET

    Brad, Aug 28, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    518
  2. Alex
    Replies:
    1
    Views:
    2,619
    Alvin Bruney [MVP]
    Feb 16, 2004
  3. Guest
    Replies:
    0
    Views:
    994
    Guest
    Apr 12, 2005
  4. Fox
    Replies:
    16
    Views:
    294
  5. Zhiguo
    Replies:
    5
    Views:
    215
    Zhiguo
    Dec 10, 2009
Loading...

Share This Page