Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

HELP: ASP JScript & VBScript interoperability

Sorry, all the code in my thread post is meant to be server-side. So if there is not a RUNAT="Server" in the SCRIPT tag then I just forgot and it should be written. Please have in mind this is all to do with server-side scripting.

How can VBScript code access JScript code variables in the same ASP page?


Dim a
a = 10


Response.Write(a);


Also, is this valid JScript code because ASP hasn't complained.


function Section(a, b, c, d) {
this.a = a;
this.memFunction = function() {
this.a = this.a + 1;
}
}


Basically it's like JScript's way of declaring classes.

How can VBScript code create a Section object?


Dim obj
obj = new Section 'Error, says cannot find Section
obj = new Section() 'Error again
obj = new Section(1, 2, 3, 4) 'Error again



Also, is it possible to nest tag inside <% %>? Like:

<%
'Some VBScript code
Class AClass
Private a
Function b()
End Function
%>

<%
End Class
%>

where JScript.asp has:


function Section() {
function Section2() {
}
}


ASP didn't complain. But couldn't test whether the JScript functions Section were member functions of the VBScript AClass.

Comments

  • CyGuyCyGuy Posts: 312Member
    : Sorry, all the code in my thread post is meant to be server-side. So
    : if there is not a RUNAT="Server" in the SCRIPT tag then I just
    : forgot and it should be written. Please have in mind this is all to
    : do with server-side scripting.
    :
    : How can VBScript code access JScript code variables in the same ASP
    : page?
    :
    :
    : Dim a
    : a = 10
    :
    :
    : Response.Write(a);
    :
    :
    : Also, is this valid JScript code because ASP hasn't complained.
    :
    :
    : function Section(a, b, c, d) {
    : this.a = a;
    : this.memFunction = function() {
    : this.a = this.a + 1;
    : }
    : }
    :
    :
    : Basically it's like JScript's way of declaring classes.
    :
    : How can VBScript code create a Section object?
    :
    :
    : Dim obj
    : obj = new Section 'Error, says cannot find Section
    : obj = new Section() 'Error again
    : obj = new Section(1, 2, 3, 4) 'Error again
    :
    :
    :
    : Also, is it possible to nest tag inside <% %>? Like:
    :
    : <%
    : 'Some VBScript code
    : Class AClass
    : Private a
    : Function b()
    : End Function
    : %>
    :
    : <%
    : End Class
    : %>
    :
    : where JScript.asp has:
    :
    :
    : function Section() {
    : function Section2() {
    : }
    : }
    :
    :
    : ASP didn't complain. But couldn't test whether the JScript functions
    : Section were member functions of the VBScript AClass.
    :
    You are looking at it all wrong. In basic HTML you can write a javascript function with VBscript, but you can not mak a VBscript function with JavaScript.... here's why.... first the VBscript is executed on the server... the result is sent to the client. ....now the javascript is run..after the page is sent!

    Got it? Okay. If you want to send data back to the server you can use a form POST or a few other techniques that send data back. But the post-back is most simple.
Sign In or Register to comment.