How do i call a function defined in html script tags from asp page?

Discussion in 'ASP General' started by thisis, Nov 1, 2006.

  1. thisis

    thisis Guest

    Hi All,

    i have this.asp page:

    <script type="text/vbscript">
    Function myFunc(val1ok, val2ok)
    ' do something ok
    myFunc = " return something ok"
    End Function
    </script>

    <html>
    <body>
    <%
    val1ok = something1
    val2ok = something2
    thenewVal = myFunc((val1ok), (val2ok))
    %>
    </body>
    </html>

    i want to call and use the returned value of Function myFunc(val1ok,
    val2ok) ,

    without omitting the html script tags and replacing them in <% %>,

    (My Question is:)

    How do i call a function defined in html script tags from asp page?
    thisis, Nov 1, 2006
    #1
    1. Advertising

  2. thisis

    Mike Brind Guest

    "thisis" <> wrote in message
    news:...
    > Hi All,
    >
    > i have this.asp page:
    >
    > <script type="text/vbscript">
    > Function myFunc(val1ok, val2ok)
    > ' do something ok
    > myFunc = " return something ok"
    > End Function
    > </script>
    >
    > <html>
    > <body>
    > <%
    > val1ok = something1
    > val2ok = something2
    > thenewVal = myFunc((val1ok), (val2ok))
    > %>
    > </body>
    > </html>
    >
    > i want to call and use the returned value of Function myFunc(val1ok,
    > val2ok) ,
    >
    > without omitting the html script tags and replacing them in <% %>,
    >
    > (My Question is:)
    >
    > How do i call a function defined in html script tags from asp page?
    >


    You can't call client-side code from server-side code. Nor vice-versa.
    Full stop.

    --
    Mike Brind
    Mike Brind, Nov 1, 2006
    #2
    1. Advertising

  3. thisis

    Tim Slattery Guest

    "thisis" <> wrote:

    >Hi All,
    >
    >i have this.asp page:
    >
    ><script type="text/vbscript">
    >Function myFunc(val1ok, val2ok)
    >' do something ok
    >myFunc = " return something ok"
    >End Function
    ></script>
    >
    ><html>
    ><body>
    ><%
    >val1ok = something1
    >val2ok = something2
    >thenewVal = myFunc((val1ok), (val2ok))
    >%>
    ></body>
    ></html>
    >
    >i want to call and use the returned value of Function myFunc(val1ok,
    >val2ok) ,
    >
    >without omitting the html script tags and replacing them in <% %>,
    >
    >(My Question is:)
    >
    >How do i call a function defined in html script tags from asp page?


    You don't. The ASP code runs on the server, producing HTML as output.
    When the ASP code finishes, the resulting HTML is sent to the client.
    The client's browser parses it, finding the Javascript code (among
    other things). Since the server-side ASP function has finished and is
    *not* sent to the client, the client-side Javascript cannot call it.
    It doesn't exist any more by the time the Javascript code runs.

    --
    Tim Slattery
    MS MVP(DTS)
    Tim Slattery, Nov 1, 2006
    #3
  4. "thisis" <> wrote in message
    news:...
    > Hi All,
    >
    > i have this.asp page:
    >
    > <script type="text/vbscript">
    > Function myFunc(val1ok, val2ok)
    > ' do something ok
    > myFunc = " return something ok"
    > End Function
    > </script>
    >
    > <html>
    > <body>
    > <%
    > val1ok = something1
    > val2ok = something2
    > thenewVal = myFunc((val1ok), (val2ok))
    > %>
    > </body>
    > </html>
    >
    > i want to call and use the returned value of Function myFunc(val1ok,
    > val2ok) ,
    >
    > without omitting the html script tags and replacing them in <% %>,
    >
    > (My Question is:)
    >
    > How do i call a function defined in html script tags from asp page?
    >


    If you have a set of functions you want to share with the client and the
    server place the functions in a VBS file. Take this example Test.vbs:-

    Function DoSomething(a, b)
    DoSomething = a + b
    End Function

    Note that since this is a vbs file it does not contain <%%>

    Now here is an example page that consumes the function both server side and
    client side:-

    <script src="test.vbs" runat="server" language="vbscript"></script>
    <html>
    <script src="test.vbs" type="text/vbscript"></script>
    <script type="text/vbscript">
    Function Body_Onload()
    divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)
    End Function
    </script>
    <body onload="Body_Onload()">
    1 + 2 = <%=DoSomething(1,2)%>
    <div id="divLocal" />
    </body>
    </html>

    Anthony.
    Anthony Jones, Nov 1, 2006
    #4
  5. thisis

    Tim Slattery Guest

    "Anthony Jones" <> wrote:


    >If you have a set of functions you want to share with the client and the
    >server place the functions in a VBS file. Take this example Test.vbs:-
    >
    >Function DoSomething(a, b)
    >DoSomething = a + b
    >End Function
    >
    >Note that since this is a vbs file it does not contain <%%>
    >
    >Now here is an example page that consumes the function both server side and
    >client side:-
    >
    ><script src="test.vbs" runat="server" language="vbscript"></script>
    ><html>
    > <script src="test.vbs" type="text/vbscript"></script>
    > <script type="text/vbscript">
    >Function Body_Onload()
    > divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)
    >End Function
    > </script>
    > <body onload="Body_Onload()">
    > 1 + 2 = <%=DoSomething(1,2)%>
    > <div id="divLocal" />
    > </body>
    ></html>


    That will work, but only with IE. Anybody using FireFox, Mozilla,
    Opera, Netscape, or any other non-MS browser won't be able to use the
    page.

    --
    Tim Slattery
    MS MVP(DTS)
    Tim Slattery, Nov 1, 2006
    #5
  6. "Tim Slattery" <> wrote in message
    news:...
    > "Anthony Jones" <> wrote:
    >
    >
    > >If you have a set of functions you want to share with the client and the
    > >server place the functions in a VBS file. Take this example Test.vbs:-
    > >
    > >Function DoSomething(a, b)
    > >DoSomething = a + b
    > >End Function
    > >
    > >Note that since this is a vbs file it does not contain <%%>
    > >
    > >Now here is an example page that consumes the function both server side

    and
    > >client side:-
    > >
    > ><script src="test.vbs" runat="server" language="vbscript"></script>
    > ><html>
    > > <script src="test.vbs" type="text/vbscript"></script>
    > > <script type="text/vbscript">
    > >Function Body_Onload()
    > > divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)
    > >End Function
    > > </script>
    > > <body onload="Body_Onload()">
    > > 1 + 2 = <%=DoSomething(1,2)%>
    > > <div id="divLocal" />
    > > </body>
    > ></html>

    >
    > That will work, but only with IE. Anybody using FireFox, Mozilla,
    > Opera, Netscape, or any other non-MS browser won't be able to use the
    > page.


    True but the OP started off with VBScript already being sent to the client
    as it was so clearly IE is the target.

    >
    > --
    > Tim Slattery
    > MS MVP(DTS)
    >
    Anthony Jones, Nov 1, 2006
    #6
  7. thisis

    thisis Guest

    Anthony Jones wrote:
    > "thisis" <> wrote in message
    > news:...
    > > Hi All,
    > >
    > > i have this.asp page:
    > >
    > > <script type="text/vbscript">
    > > Function myFunc(val1ok, val2ok)
    > > ' do something ok
    > > myFunc = " return something ok"
    > > End Function
    > > </script>
    > >
    > > <html>
    > > <body>
    > > <%
    > > val1ok = something1
    > > val2ok = something2
    > > thenewVal = myFunc((val1ok), (val2ok))
    > > %>
    > > </body>
    > > </html>
    > >
    > > i want to call and use the returned value of Function myFunc(val1ok,
    > > val2ok) ,
    > >
    > > without omitting the html script tags and replacing them in <% %>,
    > >
    > > (My Question is:)
    > >
    > > How do i call a function defined in html script tags from asp page?
    > >

    >
    > If you have a set of functions you want to share with the client and the
    > server place the functions in a VBS file. Take this example Test.vbs:-
    >
    > Function DoSomething(a, b)
    > DoSomething = a + b
    > End Function
    >
    > Note that since this is a vbs file it does not contain <%%>
    >
    > Now here is an example page that consumes the function both server side and
    > client side:-
    >
    > <script src="test.vbs" runat="server" language="vbscript"></script>
    > <html>
    > <script src="test.vbs" type="text/vbscript"></script>
    > <script type="text/vbscript">
    > Function Body_Onload()
    > divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)
    > End Function
    > </script>
    > <body onload="Body_Onload()">
    > 1 + 2 = <%=DoSomething(1,2)%>
    > <div id="divLocal" />
    > </body>
    > </html>
    >
    > Anthony.


    Hi Anthony Jones,

    i attemped to run your sample in couple on run test combinations.

    case run test 1
    ==============
    the test.vbs:

    Function DoSomething(a, b)
    DoSomething = a + b
    End Function

    the test.asp:

    1 <script src="test.vbs" runat="server" language="vbscript"></script>
    2 <html>
    3 <body>
    4 3 + 4 = <%=DoSomething(3,4)%>
    5 </body>
    6 </html>

    result:
    3 + 4 =
    Microsoft VBScript runtime error '800a000d'
    Type mismatch: 'DoSomething'
    /dt/test.asp, line 4

    My Question:case run test 1
    it seems that the script test.vbs runs on the server,
    and the the test.asp code line runs on the server too.

    So, Why do I get the Type mismatch: 'DoSomething' error?
    thisis, Nov 2, 2006
    #7
  8. thisis

    thisis Guest

    Anthony Jones wrote:
    > "thisis" <> wrote in message
    > news:...
    > > Hi All,
    > >
    > > i have this.asp page:
    > >
    > > <script type="text/vbscript">
    > > Function myFunc(val1ok, val2ok)
    > > ' do something ok
    > > myFunc = " return something ok"
    > > End Function
    > > </script>
    > >
    > > <html>
    > > <body>
    > > <%
    > > val1ok = something1
    > > val2ok = something2
    > > thenewVal = myFunc((val1ok), (val2ok))
    > > %>
    > > </body>
    > > </html>
    > >
    > > i want to call and use the returned value of Function myFunc(val1ok,
    > > val2ok) ,
    > >
    > > without omitting the html script tags and replacing them in <% %>,
    > >
    > > (My Question is:)
    > >
    > > How do i call a function defined in html script tags from asp page?
    > >

    >
    > If you have a set of functions you want to share with the client and the
    > server place the functions in a VBS file. Take this example Test.vbs:-
    >
    > Function DoSomething(a, b)
    > DoSomething = a + b
    > End Function
    >
    > Note that since this is a vbs file it does not contain <%%>
    >
    > Now here is an example page that consumes the function both server side and
    > client side:-
    >
    > <script src="test.vbs" runat="server" language="vbscript"></script>
    > <html>
    > <script src="test.vbs" type="text/vbscript"></script>
    > <script type="text/vbscript">
    > Function Body_Onload()
    > divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)
    > End Function
    > </script>
    > <body onload="Body_Onload()">
    > 1 + 2 = <%=DoSomething(1,2)%>
    > <div id="divLocal" />
    > </body>
    > </html>
    >
    > Anthony.


    Hi Anthony Jones,

    i tried to run your sample code in a couple of run time test
    combination.
    on some cases i got errors, which i don't understand why the errors
    where "produced"?

    for example:

    case run test 1
    ==============
    the test.vbs:

    Function DoSomething(a, b)
    DoSomething = a + b
    End Function

    the test.asp:

    1 <script src="test.vbs" runat="server" language="vbscript"></script>
    2 <html>
    3 <body>
    4 3 + 4 = <%=DoSomething(3,4)%>
    5 </body>
    6 </html>

    ie result:
    3 + 4 =
    Microsoft VBScript runtime error '800a000d'
    Type mismatch: 'DoSomething'
    /dt/test.asp, line 4

    My Question:case run test 1
    it seems that the script test.vbs runs on the server,
    because: script src="test.vbs" runat="server" ok.
    and, it seems that the test.asp code line runs on the server too,
    because: <% %> is in the .asp page

    So, Why do I get the Type mismatch: 'DoSomething' error?
    thisis, Nov 2, 2006
    #8
  9. "thisis" <> wrote in message
    news:...
    >
    > Anthony Jones wrote:
    > > "thisis" <> wrote in message
    > > news:...
    > > > Hi All,
    > > >
    > > > i have this.asp page:
    > > >
    > > > <script type="text/vbscript">
    > > > Function myFunc(val1ok, val2ok)
    > > > ' do something ok
    > > > myFunc = " return something ok"
    > > > End Function
    > > > </script>
    > > >
    > > > <html>
    > > > <body>
    > > > <%
    > > > val1ok = something1
    > > > val2ok = something2
    > > > thenewVal = myFunc((val1ok), (val2ok))
    > > > %>
    > > > </body>
    > > > </html>
    > > >
    > > > i want to call and use the returned value of Function myFunc(val1ok,
    > > > val2ok) ,
    > > >
    > > > without omitting the html script tags and replacing them in <% %>,
    > > >
    > > > (My Question is:)
    > > >
    > > > How do i call a function defined in html script tags from asp page?
    > > >

    > >
    > > If you have a set of functions you want to share with the client and the
    > > server place the functions in a VBS file. Take this example Test.vbs:-
    > >
    > > Function DoSomething(a, b)
    > > DoSomething = a + b
    > > End Function
    > >
    > > Note that since this is a vbs file it does not contain <%%>
    > >
    > > Now here is an example page that consumes the function both server side

    and
    > > client side:-
    > >
    > > <script src="test.vbs" runat="server" language="vbscript"></script>
    > > <html>
    > > <script src="test.vbs" type="text/vbscript"></script>
    > > <script type="text/vbscript">
    > > Function Body_Onload()
    > > divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)
    > > End Function
    > > </script>
    > > <body onload="Body_Onload()">
    > > 1 + 2 = <%=DoSomething(1,2)%>
    > > <div id="divLocal" />
    > > </body>
    > > </html>
    > >
    > > Anthony.

    >
    > Hi Anthony Jones,
    >
    > i tried to run your sample code in a couple of run time test
    > combination.
    > on some cases i got errors, which i don't understand why the errors
    > where "produced"?
    >
    > for example:
    >
    > case run test 1
    > ==============
    > the test.vbs:
    >
    > Function DoSomething(a, b)
    > DoSomething = a + b
    > End Function
    >
    > the test.asp:
    >
    > 1 <script src="test.vbs" runat="server" language="vbscript"></script>
    > 2 <html>
    > 3 <body>
    > 4 3 + 4 = <%=DoSomething(3,4)%>
    > 5 </body>
    > 6 </html>
    >
    > ie result:
    > 3 + 4 =
    > Microsoft VBScript runtime error '800a000d'
    > Type mismatch: 'DoSomething'
    > /dt/test.asp, line 4
    >
    > My Question:case run test 1
    > it seems that the script test.vbs runs on the server,
    > because: script src="test.vbs" runat="server" ok.
    > and, it seems that the test.asp code line runs on the server too,
    > because: <% %> is in the .asp page
    >
    > So, Why do I get the Type mismatch: 'DoSomething' error?
    >


    You would get this error if a test.vbs existed in the /dt folder but it
    didn't have the DoSomething function in it.

    Are you sure you've saved the vbs file?
    Anthony Jones, Nov 2, 2006
    #9
  10. thisis

    thisis Guest

    Anthony Jones wrote:
    > "thisis" <> wrote in message
    > news:...
    > >
    > > Anthony Jones wrote:
    > > > "thisis" <> wrote in message
    > > > news:...
    > > > > Hi All,
    > > > >
    > > > > i have this.asp page:
    > > > >
    > > > > <script type="text/vbscript">
    > > > > Function myFunc(val1ok, val2ok)
    > > > > ' do something ok
    > > > > myFunc = " return something ok"
    > > > > End Function
    > > > > </script>
    > > > >
    > > > > <html>
    > > > > <body>
    > > > > <%
    > > > > val1ok = something1
    > > > > val2ok = something2
    > > > > thenewVal = myFunc((val1ok), (val2ok))
    > > > > %>
    > > > > </body>
    > > > > </html>
    > > > >
    > > > > i want to call and use the returned value of Function myFunc(val1ok,
    > > > > val2ok) ,
    > > > >
    > > > > without omitting the html script tags and replacing them in <% %>,
    > > > >
    > > > > (My Question is:)
    > > > >
    > > > > How do i call a function defined in html script tags from asp page?
    > > > >
    > > >
    > > > If you have a set of functions you want to share with the client and the
    > > > server place the functions in a VBS file. Take this example Test.vbs:-
    > > >
    > > > Function DoSomething(a, b)
    > > > DoSomething = a + b
    > > > End Function
    > > >
    > > > Note that since this is a vbs file it does not contain <%%>
    > > >
    > > > Now here is an example page that consumes the function both server side

    > and
    > > > client side:-
    > > >
    > > > <script src="test.vbs" runat="server" language="vbscript"></script>
    > > > <html>
    > > > <script src="test.vbs" type="text/vbscript"></script>
    > > > <script type="text/vbscript">
    > > > Function Body_Onload()
    > > > divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)
    > > > End Function
    > > > </script>
    > > > <body onload="Body_Onload()">
    > > > 1 + 2 = <%=DoSomething(1,2)%>
    > > > <div id="divLocal" />
    > > > </body>
    > > > </html>
    > > >
    > > > Anthony.

    > >
    > > Hi Anthony Jones,
    > >
    > > i tried to run your sample code in a couple of run time test
    > > combination.
    > > on some cases i got errors, which i don't understand why the errors
    > > where "produced"?
    > >
    > > for example:
    > >
    > > case run test 1
    > > ==============
    > > the test.vbs:
    > >
    > > Function DoSomething(a, b)
    > > DoSomething = a + b
    > > End Function
    > >
    > > the test.asp:
    > >
    > > 1 <script src="test.vbs" runat="server" language="vbscript"></script>
    > > 2 <html>
    > > 3 <body>
    > > 4 3 + 4 = <%=DoSomething(3,4)%>
    > > 5 </body>
    > > 6 </html>
    > >
    > > ie result:
    > > 3 + 4 =
    > > Microsoft VBScript runtime error '800a000d'
    > > Type mismatch: 'DoSomething'
    > > /dt/test.asp, line 4
    > >
    > > My Question:case run test 1
    > > it seems that the script test.vbs runs on the server,
    > > because: script src="test.vbs" runat="server" ok.
    > > and, it seems that the test.asp code line runs on the server too,
    > > because: <% %> is in the .asp page
    > >
    > > So, Why do I get the Type mismatch: 'DoSomething' error?
    > >

    >
    > You would get this error if a test.vbs existed in the /dt folder but it
    > didn't have the DoSomething function in it.
    >
    > Are you sure you've saved the vbs file?


    Hi Anthony Jones ,

    both files test.vbs & test.asp are in the same folder/directory.
    thisis, Nov 2, 2006
    #10
  11. "thisis" <> wrote in message
    news:...
    >
    > Anthony Jones wrote:
    > > "thisis" <> wrote in message
    > > news:...
    > > >
    > > > Anthony Jones wrote:
    > > > > "thisis" <> wrote in message
    > > > > news:...
    > > > > > Hi All,
    > > > > >
    > > > > > i have this.asp page:
    > > > > >
    > > > > > <script type="text/vbscript">
    > > > > > Function myFunc(val1ok, val2ok)
    > > > > > ' do something ok
    > > > > > myFunc = " return something ok"
    > > > > > End Function
    > > > > > </script>
    > > > > >
    > > > > > <html>
    > > > > > <body>
    > > > > > <%
    > > > > > val1ok = something1
    > > > > > val2ok = something2
    > > > > > thenewVal = myFunc((val1ok), (val2ok))
    > > > > > %>
    > > > > > </body>
    > > > > > </html>
    > > > > >
    > > > > > i want to call and use the returned value of Function

    myFunc(val1ok,
    > > > > > val2ok) ,
    > > > > >
    > > > > > without omitting the html script tags and replacing them in <% %>,
    > > > > >
    > > > > > (My Question is:)
    > > > > >
    > > > > > How do i call a function defined in html script tags from asp

    page?
    > > > > >
    > > > >
    > > > > If you have a set of functions you want to share with the client and

    the
    > > > > server place the functions in a VBS file. Take this example

    Test.vbs:-
    > > > >
    > > > > Function DoSomething(a, b)
    > > > > DoSomething = a + b
    > > > > End Function
    > > > >
    > > > > Note that since this is a vbs file it does not contain <%%>
    > > > >
    > > > > Now here is an example page that consumes the function both server

    side
    > > and
    > > > > client side:-
    > > > >
    > > > > <script src="test.vbs" runat="server" language="vbscript"></script>
    > > > > <html>
    > > > > <script src="test.vbs" type="text/vbscript"></script>
    > > > > <script type="text/vbscript">
    > > > > Function Body_Onload()
    > > > > divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)
    > > > > End Function
    > > > > </script>
    > > > > <body onload="Body_Onload()">
    > > > > 1 + 2 = <%=DoSomething(1,2)%>
    > > > > <div id="divLocal" />
    > > > > </body>
    > > > > </html>
    > > > >
    > > > > Anthony.
    > > >
    > > > Hi Anthony Jones,
    > > >
    > > > i tried to run your sample code in a couple of run time test
    > > > combination.
    > > > on some cases i got errors, which i don't understand why the errors
    > > > where "produced"?
    > > >
    > > > for example:
    > > >
    > > > case run test 1
    > > > ==============
    > > > the test.vbs:
    > > >
    > > > Function DoSomething(a, b)
    > > > DoSomething = a + b
    > > > End Function
    > > >
    > > > the test.asp:
    > > >
    > > > 1 <script src="test.vbs" runat="server" language="vbscript"></script>
    > > > 2 <html>
    > > > 3 <body>
    > > > 4 3 + 4 = <%=DoSomething(3,4)%>
    > > > 5 </body>
    > > > 6 </html>
    > > >
    > > > ie result:
    > > > 3 + 4 =
    > > > Microsoft VBScript runtime error '800a000d'
    > > > Type mismatch: 'DoSomething'
    > > > /dt/test.asp, line 4
    > > >
    > > > My Question:case run test 1
    > > > it seems that the script test.vbs runs on the server,
    > > > because: script src="test.vbs" runat="server" ok.
    > > > and, it seems that the test.asp code line runs on the server too,
    > > > because: <% %> is in the .asp page
    > > >
    > > > So, Why do I get the Type mismatch: 'DoSomething' error?
    > > >

    > >
    > > You would get this error if a test.vbs existed in the /dt folder but it
    > > didn't have the DoSomething function in it.
    > >
    > > Are you sure you've saved the vbs file?

    >
    > Hi Anthony Jones ,
    >
    > both files test.vbs & test.asp are in the same folder/directory.
    >


    What server are you using. Works fine on IIS5.0 Win2K ans IIS5.1 XP Pro.If
    on IIS6 there might be security thing that needs loosening.
    Anthony Jones, Nov 2, 2006
    #11
  12. thisis

    thisis Guest

    Anthony Jones wrote:
    > "thisis" <> wrote in message
    > news:...
    > >
    > > Anthony Jones wrote:
    > > > "thisis" <> wrote in message
    > > > news:...
    > > > >
    > > > > Anthony Jones wrote:
    > > > > > "thisis" <> wrote in message
    > > > > > news:...
    > > > > > > Hi All,
    > > > > > >
    > > > > > > i have this.asp page:
    > > > > > >
    > > > > > > <script type="text/vbscript">
    > > > > > > Function myFunc(val1ok, val2ok)
    > > > > > > ' do something ok
    > > > > > > myFunc = " return something ok"
    > > > > > > End Function
    > > > > > > </script>
    > > > > > >
    > > > > > > <html>
    > > > > > > <body>
    > > > > > > <%
    > > > > > > val1ok = something1
    > > > > > > val2ok = something2
    > > > > > > thenewVal = myFunc((val1ok), (val2ok))
    > > > > > > %>
    > > > > > > </body>
    > > > > > > </html>
    > > > > > >
    > > > > > > i want to call and use the returned value of Function

    > myFunc(val1ok,
    > > > > > > val2ok) ,
    > > > > > >
    > > > > > > without omitting the html script tags and replacing them in <% %>,
    > > > > > >
    > > > > > > (My Question is:)
    > > > > > >
    > > > > > > How do i call a function defined in html script tags from asp

    > page?
    > > > > > >
    > > > > >
    > > > > > If you have a set of functions you want to share with the client and

    > the
    > > > > > server place the functions in a VBS file. Take this example

    > Test.vbs:-
    > > > > >
    > > > > > Function DoSomething(a, b)
    > > > > > DoSomething = a + b
    > > > > > End Function
    > > > > >
    > > > > > Note that since this is a vbs file it does not contain <%%>
    > > > > >
    > > > > > Now here is an example page that consumes the function both server

    > side
    > > > and
    > > > > > client side:-
    > > > > >
    > > > > > <script src="test.vbs" runat="server" language="vbscript"></script>
    > > > > > <html>
    > > > > > <script src="test.vbs" type="text/vbscript"></script>
    > > > > > <script type="text/vbscript">
    > > > > > Function Body_Onload()
    > > > > > divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)
    > > > > > End Function
    > > > > > </script>
    > > > > > <body onload="Body_Onload()">
    > > > > > 1 + 2 = <%=DoSomething(1,2)%>
    > > > > > <div id="divLocal" />
    > > > > > </body>
    > > > > > </html>
    > > > > >
    > > > > > Anthony.
    > > > >
    > > > > Hi Anthony Jones,
    > > > >
    > > > > i tried to run your sample code in a couple of run time test
    > > > > combination.
    > > > > on some cases i got errors, which i don't understand why the errors
    > > > > where "produced"?
    > > > >
    > > > > for example:
    > > > >
    > > > > case run test 1
    > > > > ==============
    > > > > the test.vbs:
    > > > >
    > > > > Function DoSomething(a, b)
    > > > > DoSomething = a + b
    > > > > End Function
    > > > >
    > > > > the test.asp:
    > > > >
    > > > > 1 <script src="test.vbs" runat="server" language="vbscript"></script>
    > > > > 2 <html>
    > > > > 3 <body>
    > > > > 4 3 + 4 = <%=DoSomething(3,4)%>
    > > > > 5 </body>
    > > > > 6 </html>
    > > > >
    > > > > ie result:
    > > > > 3 + 4 =
    > > > > Microsoft VBScript runtime error '800a000d'
    > > > > Type mismatch: 'DoSomething'
    > > > > /dt/test.asp, line 4
    > > > >
    > > > > My Question:case run test 1
    > > > > it seems that the script test.vbs runs on the server,
    > > > > because: script src="test.vbs" runat="server" ok.
    > > > > and, it seems that the test.asp code line runs on the server too,
    > > > > because: <% %> is in the .asp page
    > > > >
    > > > > So, Why do I get the Type mismatch: 'DoSomething' error?
    > > > >
    > > >
    > > > You would get this error if a test.vbs existed in the /dt folder but it
    > > > didn't have the DoSomething function in it.
    > > >
    > > > Are you sure you've saved the vbs file?

    > >
    > > Hi Anthony Jones ,
    > >
    > > both files test.vbs & test.asp are in the same folder/directory.
    > >

    >
    > What server are you using. Works fine on IIS5.0 Win2K ans IIS5.1 XP Pro.If
    > on IIS6 there might be security thing that needs loosening.


    Hi Anthony Jones,

    i'm using a "small" version of iis, pws 4.0 win98/add0n.
    there is no tighten security.

    it's reads odd that on one ms server as yours, and on other server as
    mine,
    the code behaves diffrently.

    i think, if the code was proper the issue wouldn't come up.

    i run into this article which i thibk is valid for my topic:

    http://www.exodus-dev.com/techtips/asp_script_runat_vs_render_blocks.htm
    thisis, Nov 3, 2006
    #12
  13. thisis

    thisis Guest

    Anthony Jones wrote:
    > "thisis" <> wrote in message
    > news:...
    > > Hi All,
    > >
    > > i have this.asp page:
    > >
    > > <script type="text/vbscript">
    > > Function myFunc(val1ok, val2ok)
    > > ' do something ok
    > > myFunc = " return something ok"
    > > End Function
    > > </script>
    > >
    > > <html>
    > > <body>
    > > <%
    > > val1ok = something1
    > > val2ok = something2
    > > thenewVal = myFunc((val1ok), (val2ok))
    > > %>
    > > </body>
    > > </html>
    > >
    > > i want to call and use the returned value of Function myFunc(val1ok,
    > > val2ok) ,
    > >
    > > without omitting the html script tags and replacing them in <% %>,
    > >
    > > (My Question is:)
    > >
    > > How do i call a function defined in html script tags from asp page?
    > >

    >
    > If you have a set of functions you want to share with the client and the
    > server place the functions in a VBS file. Take this example Test.vbs:-
    >
    > Function DoSomething(a, b)
    > DoSomething = a + b
    > End Function
    >
    > Note that since this is a vbs file it does not contain <%%>
    >
    > Now here is an example page that consumes the function both server side and
    > client side:-
    >
    > <script src="test.vbs" runat="server" language="vbscript"></script>
    > <html>
    > <script src="test.vbs" type="text/vbscript"></script>
    > <script type="text/vbscript">
    > Function Body_Onload()
    > divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)
    > End Function
    > </script>
    > <body onload="Body_Onload()">
    > 1 + 2 = <%=DoSomething(1,2)%>
    > <div id="divLocal" />
    > </body>
    > </html>
    >
    > Anthony.


    Hi Anthony Jones (again today),

    i managed to run your sample code with a slight changes.

    in the test.asp
    i replaced the first line in your sample, yourLine:
    <script src="test.vbs" runat="server" language="vbscript"></script>
    with thisLine:
    <!-- #include file = test.inc -->

    the new test.asp :

    <!-- #include file = test.inc -->
    <script src="test.vb" runat="server" language="vbscript"></script>
    <html>
    <script src="test.vbs" type="text/vbscript"></script>
    <script type="text/vbscript">
    Function Body_Onload()
    divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)
    End Function
    </script>
    <body onload="Body_Onload()">
    1 + 2 = <%=DoSomething(1,2)%>
    <div id="divLocal" />
    </body>
    </html>


    and i added a new file test inc:
    <%
    Function DoSomething(a, b)
    DoSomething = a + b
    End Function
    %>

    the code runs with no errors.

    but damm, i was trying to avoid using <% %> in the first place.
    that's issue returns me again to the starting point of this topic
    thread.


    (reminder):

    i have this.asp page:


    <script type="text/vbscript">
    Function myFunc(val1ok, val2ok)
    ' do something ok
    myFunc = " return something ok"
    End Function
    </script>


    <html>
    <body>
    <%
    val1ok = something1
    val2ok = something2
    thenewVal = myFunc((val1ok), (val2ok))
    %>
    </body>
    </html>


    i want to call and use the returned value of Function myFunc(val1ok,
    val2ok) ,


    without omitting the html script tags and replacing them in <% %>,


    (My Question is:)


    How do i call a function defined in html script tags from asp page?
    thisis, Nov 3, 2006
    #13
  14. > > > > >
    > > > > > Hi Anthony Jones,
    > > > > >
    > > > > > i tried to run your sample code in a couple of run time test
    > > > > > combination.
    > > > > > on some cases i got errors, which i don't understand why the

    errors
    > > > > > where "produced"?
    > > > > >
    > > > > > for example:
    > > > > >
    > > > > > case run test 1
    > > > > > ==============
    > > > > > the test.vbs:
    > > > > >
    > > > > > Function DoSomething(a, b)
    > > > > > DoSomething = a + b
    > > > > > End Function
    > > > > >
    > > > > > the test.asp:
    > > > > >
    > > > > > 1 <script src="test.vbs" runat="server"

    language="vbscript"></script>
    > > > > > 2 <html>
    > > > > > 3 <body>
    > > > > > 4 3 + 4 = <%=DoSomething(3,4)%>
    > > > > > 5 </body>
    > > > > > 6 </html>
    > > > > >
    > > > > > ie result:
    > > > > > 3 + 4 =
    > > > > > Microsoft VBScript runtime error '800a000d'
    > > > > > Type mismatch: 'DoSomething'
    > > > > > /dt/test.asp, line 4
    > > > > >
    > > > > > My Question:case run test 1
    > > > > > it seems that the script test.vbs runs on the server,
    > > > > > because: script src="test.vbs" runat="server" ok.
    > > > > > and, it seems that the test.asp code line runs on the server too,
    > > > > > because: <% %> is in the .asp page
    > > > > >
    > > > > > So, Why do I get the Type mismatch: 'DoSomething' error?
    > > > > >
    > > > >
    > > > > You would get this error if a test.vbs existed in the /dt folder but

    it
    > > > > didn't have the DoSomething function in it.
    > > > >
    > > > > Are you sure you've saved the vbs file?
    > > >
    > > > Hi Anthony Jones ,
    > > >
    > > > both files test.vbs & test.asp are in the same folder/directory.
    > > >

    > >
    > > What server are you using. Works fine on IIS5.0 Win2K ans IIS5.1 XP

    Pro.If
    > > on IIS6 there might be security thing that needs loosening.

    >
    > Hi Anthony Jones,
    >
    > i'm using a "small" version of iis, pws 4.0 win98/add0n.
    > there is no tighten security.
    >
    > it's reads odd that on one ms server as yours, and on other server as
    > mine,
    > the code behaves diffrently.
    >
    > i think, if the code was proper the issue wouldn't come up.
    >
    > i run into this article which i thibk is valid for my topic:
    >
    > http://www.exodus-dev.com/techtips/asp_script_runat_vs_render_blocks.htm
    >


    This isn't applicable in the case where the VBS file contains only a set of
    functions.
    Anthony Jones, Nov 3, 2006
    #14
  15. "thisis" <> wrote in message
    news:...
    >
    > Anthony Jones wrote:
    > > "thisis" <> wrote in message
    > > news:...
    > > > Hi All,
    > > >
    > > > i have this.asp page:
    > > >
    > > > <script type="text/vbscript">
    > > > Function myFunc(val1ok, val2ok)
    > > > ' do something ok
    > > > myFunc = " return something ok"
    > > > End Function
    > > > </script>
    > > >
    > > > <html>
    > > > <body>
    > > > <%
    > > > val1ok = something1
    > > > val2ok = something2
    > > > thenewVal = myFunc((val1ok), (val2ok))
    > > > %>
    > > > </body>
    > > > </html>
    > > >
    > > > i want to call and use the returned value of Function myFunc(val1ok,
    > > > val2ok) ,
    > > >
    > > > without omitting the html script tags and replacing them in <% %>,
    > > >
    > > > (My Question is:)
    > > >
    > > > How do i call a function defined in html script tags from asp page?
    > > >

    > >
    > > If you have a set of functions you want to share with the client and the
    > > server place the functions in a VBS file. Take this example Test.vbs:-
    > >
    > > Function DoSomething(a, b)
    > > DoSomething = a + b
    > > End Function
    > >
    > > Note that since this is a vbs file it does not contain <%%>
    > >
    > > Now here is an example page that consumes the function both server side

    and
    > > client side:-
    > >
    > > <script src="test.vbs" runat="server" language="vbscript"></script>
    > > <html>
    > > <script src="test.vbs" type="text/vbscript"></script>
    > > <script type="text/vbscript">
    > > Function Body_Onload()
    > > divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)
    > > End Function
    > > </script>
    > > <body onload="Body_Onload()">
    > > 1 + 2 = <%=DoSomething(1,2)%>
    > > <div id="divLocal" />
    > > </body>
    > > </html>
    > >
    > > Anthony.

    >
    > Hi Anthony Jones (again today),
    >
    > i managed to run your sample code with a slight changes.
    >
    > in the test.asp
    > i replaced the first line in your sample, yourLine:
    > <script src="test.vbs" runat="server" language="vbscript"></script>
    > with thisLine:
    > <!-- #include file = test.inc -->
    >
    > the new test.asp :
    >
    > <!-- #include file = test.inc -->
    > <script src="test.vb" runat="server" language="vbscript"></script>
    > <html>
    > <script src="test.vbs" type="text/vbscript"></script>
    > <script type="text/vbscript">
    > Function Body_Onload()
    > divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)
    > End Function
    > </script>
    > <body onload="Body_Onload()">
    > 1 + 2 = <%=DoSomething(1,2)%>
    > <div id="divLocal" />
    > </body>
    > </html>
    >
    >
    > and i added a new file test inc:
    > <%
    > Function DoSomething(a, b)
    > DoSomething = a + b
    > End Function
    > %>
    >


    That just defeats the whole point of what you were trying to do. You only
    want to have the VBScript code in one place. If you need to change
    something in test.vbs you now need to replicate the change in test.inc. I
    don't have access to Win98/PWS to test this but it doesn't surprise me that
    it has different behaviour. I suspect it doesn't support the runat="server"
    attribute.

    > the code runs with no errors.
    >
    > but damm, i was trying to avoid using <% %> in the first place.
    > that's issue returns me again to the starting point of this topic
    > thread.
    >
    >
    > (reminder):
    >
    > i have this.asp page:
    >
    >
    > <script type="text/vbscript">
    > Function myFunc(val1ok, val2ok)
    > ' do something ok
    > myFunc = " return something ok"
    > End Function
    > </script>
    >
    >
    > <html>
    > <body>
    > <%
    > val1ok = something1
    > val2ok = something2
    > thenewVal = myFunc((val1ok), (val2ok))
    > %>
    > </body>
    > </html>
    >
    >
    > i want to call and use the returned value of Function myFunc(val1ok,
    > val2ok) ,
    >
    >
    > without omitting the html script tags and replacing them in <% %>,
    >
    >
    > (My Question is:)
    >
    >
    > How do i call a function defined in html script tags from asp page?
    >


    Without runat="server" support? I can't see how you can.

    You might try this:-

    <%
    <!-- #include file="test.vbs" -->
    %>
    <html>
    <body>
    3 + 4 = <%=DoSomething(3,4)%>
    </body>
    </html>

    It doesn't work in IIS but you never know, perhaps you can get away with it
    in PWS.
    Anthony Jones, Nov 3, 2006
    #15
  16. thisis

    thisis Guest

    Anthony Jones wrote:
    > "thisis" <> wrote in message
    > news:...
    > >
    > > Anthony Jones wrote:
    > > > "thisis" <> wrote in message
    > > > news:...
    > > > > Hi All,
    > > > >
    > > > > i have this.asp page:
    > > > >
    > > > > <script type="text/vbscript">
    > > > > Function myFunc(val1ok, val2ok)
    > > > > ' do something ok
    > > > > myFunc = " return something ok"
    > > > > End Function
    > > > > </script>
    > > > >
    > > > > <html>
    > > > > <body>
    > > > > <%
    > > > > val1ok = something1
    > > > > val2ok = something2
    > > > > thenewVal = myFunc((val1ok), (val2ok))
    > > > > %>
    > > > > </body>
    > > > > </html>
    > > > >
    > > > > i want to call and use the returned value of Function myFunc(val1ok,
    > > > > val2ok) ,
    > > > >
    > > > > without omitting the html script tags and replacing them in <% %>,
    > > > >
    > > > > (My Question is:)
    > > > >
    > > > > How do i call a function defined in html script tags from asp page?
    > > > >
    > > >
    > > > If you have a set of functions you want to share with the client and the
    > > > server place the functions in a VBS file. Take this example Test.vbs:-
    > > >
    > > > Function DoSomething(a, b)
    > > > DoSomething = a + b
    > > > End Function
    > > >
    > > > Note that since this is a vbs file it does not contain <%%>
    > > >
    > > > Now here is an example page that consumes the function both server side

    > and
    > > > client side:-
    > > >
    > > > <script src="test.vbs" runat="server" language="vbscript"></script>
    > > > <html>
    > > > <script src="test.vbs" type="text/vbscript"></script>
    > > > <script type="text/vbscript">
    > > > Function Body_Onload()
    > > > divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)
    > > > End Function
    > > > </script>
    > > > <body onload="Body_Onload()">
    > > > 1 + 2 = <%=DoSomething(1,2)%>
    > > > <div id="divLocal" />
    > > > </body>
    > > > </html>
    > > >
    > > > Anthony.

    > >
    > > Hi Anthony Jones (again today),
    > >
    > > i managed to run your sample code with a slight changes.
    > >
    > > in the test.asp
    > > i replaced the first line in your sample, yourLine:
    > > <script src="test.vbs" runat="server" language="vbscript"></script>
    > > with thisLine:
    > > <!-- #include file = test.inc -->
    > >
    > > the new test.asp :
    > >
    > > <!-- #include file = test.inc -->
    > > <script src="test.vb" runat="server" language="vbscript"></script>
    > > <html>
    > > <script src="test.vbs" type="text/vbscript"></script>
    > > <script type="text/vbscript">
    > > Function Body_Onload()
    > > divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)
    > > End Function
    > > </script>
    > > <body onload="Body_Onload()">
    > > 1 + 2 = <%=DoSomething(1,2)%>
    > > <div id="divLocal" />
    > > </body>
    > > </html>
    > >
    > >
    > > and i added a new file test inc:
    > > <%
    > > Function DoSomething(a, b)
    > > DoSomething = a + b
    > > End Function
    > > %>
    > >

    >
    > That just defeats the whole point of what you were trying to do. You only
    > want to have the VBScript code in one place. If you need to change
    > something in test.vbs you now need to replicate the change in test.inc. I
    > don't have access to Win98/PWS to test this but it doesn't surprise me that
    > it has different behaviour. I suspect it doesn't support the runat="server"
    > attribute.
    >
    > > the code runs with no errors.
    > >
    > > but damm, i was trying to avoid using <% %> in the first place.
    > > that's issue returns me again to the starting point of this topic
    > > thread.
    > >
    > >
    > > (reminder):
    > >
    > > i have this.asp page:
    > >
    > >
    > > <script type="text/vbscript">
    > > Function myFunc(val1ok, val2ok)
    > > ' do something ok
    > > myFunc = " return something ok"
    > > End Function
    > > </script>
    > >
    > >
    > > <html>
    > > <body>
    > > <%
    > > val1ok = something1
    > > val2ok = something2
    > > thenewVal = myFunc((val1ok), (val2ok))
    > > %>
    > > </body>
    > > </html>
    > >
    > >
    > > i want to call and use the returned value of Function myFunc(val1ok,
    > > val2ok) ,
    > >
    > >
    > > without omitting the html script tags and replacing them in <% %>,
    > >
    > >
    > > (My Question is:)
    > >
    > >
    > > How do i call a function defined in html script tags from asp page?
    > >

    >
    > Without runat="server" support? I can't see how you can.
    >
    > You might try this:-
    >
    > <%
    > <!-- #include file="test.vbs" -->
    > %>
    > <html>
    > <body>
    > 3 + 4 = <%=DoSomething(3,4)%>
    > </body>
    > </html>
    >
    > It doesn't work in IIS but you never know, perhaps you can get away with it
    > in PWS.


    Hi Anthony Jones,

    (btw - pws does support runat="server", don't blame the machine for our
    lack of skills)


    this line, will not work, it is not a valid line in asp rules.
    the reason for that, is :
    the following script will not work because ASP executes the #include
    directive before it assigns a value to the variable.
    ref: [http://www.w3schools.com/asp/asp_incfiles.asp]

    <%
    <!-- #include file="test.vbs" -->
    %>
    thisis, Nov 3, 2006
    #16

  17. >
    > Hi Anthony Jones,
    >
    > (btw - pws does support runat="server", don't blame the machine for our
    > lack of skills)
    >
    >


    So if runat server is supported in PWS then the example I gave should work.

    If I go through these steps exactly (can you follow them verbatim?) :-

    Create a file called test.vbs in a folder (lets also call it test) under the
    root folder of the local website:-

    Function DoSomething(a, b)
    DoSomething = a + b
    End Function

    Now in the same folder I create test.asp that has this content:-

    <script src="test.vbs" runat="server" language="vbscript"></script>
    <html>
    <script src="test.vbs" type="text/vbscript"></script>
    <script type="text/vbscript">
    Function Body_Onload()
    divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)
    End Function
    </script>
    <body onload="Body_Onload()">
    1 + 2 = <%=DoSomething(1,2)%>
    <div id="divLocal" />
    </body>
    </html>

    Now in IE6 I visit http://localhost/test/test.asp

    I see:-

    1 + 2 = 3
    3 + 4 = 7

    but you get a type mismatch when excuteing DoSomething in <% %>. Which
    indicates that the DoSomething function hasn't been created. If that's how
    PWS (which is ASP 2.0) works there is little point in it supporting the
    runat="server" attribute.


    > this line, will not work, it is not a valid line in asp rules.
    > the reason for that, is :
    > the following script will not work because ASP executes the #include
    > directive before it assigns a value to the variable.
    > ref: [http://www.w3schools.com/asp/asp_incfiles.asp]
    >
    > <%
    > <!-- #include file="test.vbs" -->
    > %>
    >


    Oh well it was a longshot based on the apparently the PWS not doing exactly
    what I see in an IIS implementation.
    Anthony Jones, Nov 3, 2006
    #17
  18. thisis

    thisis Guest

    Anthony Jones wrote:
    > >
    > > Hi Anthony Jones,
    > >
    > > (btw - pws does support runat="server", don't blame the machine for our
    > > lack of skills)
    > >
    > >

    >
    > So if runat server is supported in PWS then the example I gave should work.
    >
    > If I go through these steps exactly (can you follow them verbatim?) :-
    >
    > Create a file called test.vbs in a folder (lets also call it test) under the
    > root folder of the local website:-
    >
    > Function DoSomething(a, b)
    > DoSomething = a + b
    > End Function
    >
    > Now in the same folder I create test.asp that has this content:-
    >
    > <script src="test.vbs" runat="server" language="vbscript"></script>
    > <html>
    > <script src="test.vbs" type="text/vbscript"></script>
    > <script type="text/vbscript">
    > Function Body_Onload()
    > divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)
    > End Function
    > </script>
    > <body onload="Body_Onload()">
    > 1 + 2 = <%=DoSomething(1,2)%>
    > <div id="divLocal" />
    > </body>
    > </html>
    >
    > Now in IE6 I visit http://localhost/test/test.asp
    >
    > I see:-
    >
    > 1 + 2 = 3
    > 3 + 4 = 7
    >
    > but you get a type mismatch when excuteing DoSomething in <% %>. Which
    > indicates that the DoSomething function hasn't been created. If that's how
    > PWS (which is ASP 2.0) works there is little point in it supporting the
    > runat="server" attribute.
    >
    >
    > > this line, will not work, it is not a valid line in asp rules.
    > > the reason for that, is :
    > > the following script will not work because ASP executes the #include
    > > directive before it assigns a value to the variable.
    > > ref: [http://www.w3schools.com/asp/asp_incfiles.asp]
    > >
    > > <%
    > > <!-- #include file="test.vbs" -->
    > > %>
    > >

    >
    > Oh well it was a longshot based on the apparently the PWS not doing exactly
    > what I see in an IIS implementation.



    Hi Anthony Jones,


    i did exactly what you worte word by word:

    1. i created the file test.asp with the relevant code.
    2. i created the file test.vbs , in the same folder of step 1, with the
    relevant code.
    3. i rechecked that my pws supports <script runat="server" ...>, and it
    does - i've an app that uses <script runat="server" ...>.
    4. i rechecked that there are no security issues, and there are no
    security on my pws.
    5. i "mapped" the relevant virtual folder, and the results are i) & ii)

    i)
    on the ie 6.0 window i get:
    -------------------------------------------------
    | 1 + 2 = |
    | |
    | Microsoft VBScript runtime error '800a000d' |
    | |
    | Type mismatch: 'DoSomething' |
    | |
    | /dt/test.asp, line 10 |
    -------------------------------------------------

    ii)
    on the ie 6.0 error message box -
    - see ie menu tools/internet options/advanced/enable script error
    notify... -

    i get this:
    ---------------------------------------
    | Line: 6 |
    | Char: 2 |
    | Error: Object required: 'divLocal' |
    | Code: 0 |
    | URL: http:/127.0.0.1/dt/test.asp |
    ---------------------------------------

    So you susspect that my pws does not support the runat="server" solemn
    attribute.

    On my global.asa i use this attribute,

    <script language="VBScript" runat="Server">
    Sub Application_OnStart
    </script>
    <script language="VBScript" runat="Server">
    <!-- #include file="incs/globalasa/globApsOSDefault.inc" -->
    </script>

    <script language="VBScript" runat="Server">
    END Sub
    </script>

    <script language="VBScript" runat="Server">
    Sub Application_OnEnd
    </script>
    <script language="VBScript" runat="Server">
    <!-- #include file="incs/globalasa/globApsOEDefault.inc" -->
    </script>

    <script language="VBScript" runat="Server">
    END Sub
    </script>
    (end of global.asa)


    and for instance, on globApsOSDefault.inc:

    <script language="VBScript" runat="Server">
    ' set application variables requires reboot
    Application("countVisitors") = 0
    Application("dateAppStarted") = now()
    </script>

    i think, correct me if i'm worng, that my pws does support
    runat="Server",
    but does not support functions defined in this manner of syntex:
    <script runat="server" src="test.vbs" language="vbscript"></script>

    a. what do you think, what other options have i got to get a valid run
    of the line:
    <script src="test.vbs" runat="server" language="vbscript"
    type="text/vbscript">?
    b. is the code line:
    <script runat="server" language="vbscript" type="text/vbscript">
    <!-- #include file = "test.inc" -->
    </script>
    is equal to:
    <script src="test.vbs" runat="server" language="vbscript"></script>
    regarding the order of execution and running the code on the server?
    test.inc:
    <%
    Function DoSomething(a, b)
    DoSomething = a + b
    End Function
    %>
    thisis, Nov 4, 2006
    #18
  19. thisis

    thisis Guest

    Anthony Jones wrote:
    > >
    > > Hi Anthony Jones,
    > >
    > > (btw - pws does support runat="server", don't blame the machine for our
    > > lack of skills)
    > >
    > >

    >
    > So if runat server is supported in PWS then the example I gave should work.
    >
    > If I go through these steps exactly (can you follow them verbatim?) :-
    >
    > Create a file called test.vbs in a folder (lets also call it test) under the
    > root folder of the local website:-
    >
    > Function DoSomething(a, b)
    > DoSomething = a + b
    > End Function
    >
    > Now in the same folder I create test.asp that has this content:-
    >
    > <script src="test.vbs" runat="server" language="vbscript"></script>
    > <html>
    > <script src="test.vbs" type="text/vbscript"></script>
    > <script type="text/vbscript">
    > Function Body_Onload()
    > divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)
    > End Function
    > </script>
    > <body onload="Body_Onload()">
    > 1 + 2 = <%=DoSomething(1,2)%>
    > <div id="divLocal" />
    > </body>
    > </html>
    >
    > Now in IE6 I visit http://localhost/test/test.asp
    >
    > I see:-
    >
    > 1 + 2 = 3
    > 3 + 4 = 7
    >
    > but you get a type mismatch when excuteing DoSomething in <% %>. Which
    > indicates that the DoSomething function hasn't been created. If that's how
    > PWS (which is ASP 2.0) works there is little point in it supporting the
    > runat="server" attribute.
    >
    >
    > > this line, will not work, it is not a valid line in asp rules.
    > > the reason for that, is :
    > > the following script will not work because ASP executes the #include
    > > directive before it assigns a value to the variable.
    > > ref: [http://www.w3schools.com/asp/asp_incfiles.asp]
    > >
    > > <%
    > > <!-- #include file="test.vbs" -->
    > > %>
    > >

    >
    > Oh well it was a longshot based on the apparently the PWS not doing exactly
    > what I see in an IIS implementation.



    Hi Anthony Jones,


    i did exactly what you worte word by word:

    1. i created the file test.asp with the relevant code.
    2. i created the file test.vbs , in the same folder of step 1, with the
    relevant code.
    3. i rechecked that my pws supports <script runat="server" ...>, and it
    does - i've an app that uses <script runat="server" ...>.
    4. i rechecked that there are no security issues, and there are no
    security on my pws.
    5. i "mapped" the relevant virtual folder, and the results are i) & ii)

    i)
    on the ie 6.0 window i get:
    -------------------------------------------------
    | 1 + 2 = |
    | |
    | Microsoft VBScript runtime error '800a000d' |
    | |
    | Type mismatch: 'DoSomething' |
    | |
    | /dt/test.asp, line 10 |
    -------------------------------------------------

    ii)
    on the ie 6.0 error message box -
    - see ie menu tools/internet options/advanced/enable script error
    notify... -

    i get this:
    -----------------------------------------
    | Line: 6 |
    | Char: 2 |
    | Error: Object required: 'divLocal' |
    | Code: 0 |
    | URL: http:/127.0.0.1/dt/test.asp |
    -----------------------------------------

    So you susspect that my pws does not support the runat="server" solemn
    attribute.

    On my global.asa i use this attribute,

    <script language="VBScript" runat="Server">
    Sub Application_OnStart
    </script>
    <script language="VBScript" runat="Server">
    <!-- #include file="incs/globalasa/globApsOSDefault.inc" -->
    </script>

    <script language="VBScript" runat="Server">
    END Sub
    </script>

    <script language="VBScript" runat="Server">
    Sub Application_OnEnd
    </script>
    <script language="VBScript" runat="Server">
    <!-- #include file="incs/globalasa/globApsOEDefault.inc" -->
    </script>

    <script language="VBScript" runat="Server">
    END Sub
    </script>
    (end of global.asa)


    and for instance, on globApsOSDefault.inc:

    <script language="VBScript" runat="Server">
    ' set application variables requires reboot
    Application("countVisitors") = 0
    Application("dateAppStarted") = now()
    </script>

    i think, correct me if i'm worng, that my pws does support
    runat="Server",
    but does not support functions defined in this manner of syntex:
    <script runat="server" src="test.vbs" language="vbscript"></script>

    a. what do you think, what other options have i got to get a valid run
    of the line:
    <script src="test.vbs" runat="server" language="vbscript"
    type="text/vbscript">?
    b. is the code line:
    <script runat="server" language="vbscript" type="text/vbscript">
    <!-- #include file = "test.inc" -->
    </script>
    is equal to:
    <script src="test.vbs" runat="server" language="vbscript"></script>
    regarding the order of execution and running the code on the server?
    test.inc:
    <%
    Function DoSomething(a, b)
    DoSomething = a + b
    End Function
    %>
    thisis, Nov 4, 2006
    #19
  20. "thisis" <> wrote in message
    news:...
    >
    > Anthony Jones wrote:
    > > >
    > > > Hi Anthony Jones,
    > > >
    > > > (btw - pws does support runat="server", don't blame the machine for

    our
    > > > lack of skills)
    > > >
    > > >

    > >
    > > So if runat server is supported in PWS then the example I gave should

    work.
    > >
    > > If I go through these steps exactly (can you follow them verbatim?) :-
    > >
    > > Create a file called test.vbs in a folder (lets also call it test) under

    the
    > > root folder of the local website:-
    > >
    > > Function DoSomething(a, b)
    > > DoSomething = a + b
    > > End Function
    > >
    > > Now in the same folder I create test.asp that has this content:-
    > >
    > > <script src="test.vbs" runat="server" language="vbscript"></script>
    > > <html>
    > > <script src="test.vbs" type="text/vbscript"></script>
    > > <script type="text/vbscript">
    > > Function Body_Onload()
    > > divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)
    > > End Function
    > > </script>
    > > <body onload="Body_Onload()">
    > > 1 + 2 = <%=DoSomething(1,2)%>
    > > <div id="divLocal" />
    > > </body>
    > > </html>
    > >
    > > Now in IE6 I visit http://localhost/test/test.asp
    > >
    > > I see:-
    > >
    > > 1 + 2 = 3
    > > 3 + 4 = 7
    > >
    > > but you get a type mismatch when excuteing DoSomething in <% %>. Which
    > > indicates that the DoSomething function hasn't been created. If that's

    how
    > > PWS (which is ASP 2.0) works there is little point in it supporting the
    > > runat="server" attribute.
    > >
    > >
    > > > this line, will not work, it is not a valid line in asp rules.
    > > > the reason for that, is :
    > > > the following script will not work because ASP executes the #include
    > > > directive before it assigns a value to the variable.
    > > > ref: [http://www.w3schools.com/asp/asp_incfiles.asp]
    > > >
    > > > <%
    > > > <!-- #include file="test.vbs" -->
    > > > %>
    > > >

    > >
    > > Oh well it was a longshot based on the apparently the PWS not doing

    exactly
    > > what I see in an IIS implementation.

    >
    >
    > Hi Anthony Jones,
    >
    >
    > i did exactly what you worte word by word:
    >
    > 1. i created the file test.asp with the relevant code.
    > 2. i created the file test.vbs , in the same folder of step 1, with the
    > relevant code.
    > 3. i rechecked that my pws supports <script runat="server" ...>, and it
    > does - i've an app that uses <script runat="server" ...>.
    > 4. i rechecked that there are no security issues, and there are no
    > security on my pws.
    > 5. i "mapped" the relevant virtual folder, and the results are i) & ii)
    >
    > i)
    > on the ie 6.0 window i get:
    > -------------------------------------------------
    > | 1 + 2 = |
    > | |
    > | Microsoft VBScript runtime error '800a000d' |
    > | |
    > | Type mismatch: 'DoSomething' |
    > | |
    > | /dt/test.asp, line 10 |
    > -------------------------------------------------


    The above output shows that the clientside function isn't working.

    The runat server is working.

    >
    > ii)
    > on the ie 6.0 error message box -
    > - see ie menu tools/internet options/advanced/enable script error
    > notify... -
    >
    > i get this:
    > ---------------------------------------
    > | Line: 6 |
    > | Char: 2 |
    > | Error: Object required: 'divLocal' |
    > | Code: 0 |
    > | URL: http:/127.0.0.1/dt/test.asp |
    > ---------------------------------------
    >
    > So you susspect that my pws does not support the runat="server" solemn
    > attribute.


    It's the clientside that doesn't appear to be working in this case.

    Try this for the body_onload function (keep everything as I've specified)

    Function Body_Onload()
    window.divLocal.innerHTML = "3 + 4 = " & DoSomething(3,4)
    End Function

    Other variations:-

    Function Body_Onload()
    document.getElementById("divLocal").innerHTML = "3 + 4 = " &
    DoSomething(3,4)
    End Function

    Function Body_Onload()
    window.document.getElementById("divLocal").innerHTML = "3 + 4 = " &
    DoSomething(3,4)
    End Function
    Anthony Jones, Nov 5, 2006
    #20
    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. Dean H. Saxe
    Replies:
    0
    Views:
    1,011
    Dean H. Saxe
    Jan 3, 2004
  2. Rob Nicholson
    Replies:
    3
    Views:
    662
    Rob Nicholson
    May 28, 2005
  3. Donald Firesmith

    html tags within meta tags allowed?

    Donald Firesmith, Jan 5, 2005, in forum: XML
    Replies:
    5
    Views:
    870
    Andy Dingley
    Jan 8, 2005
  4. Oodini
    Replies:
    1
    Views:
    1,749
    Keith Thompson
    Sep 27, 2005
  5. Alok
    Replies:
    3
    Views:
    237
Loading...

Share This Page