Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to run vb-script on server side without submitting a form ?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
There's a FAQ about this question :

The problem is I can't use the solution suggested here.
For a school project, we must make an application by only using HTML/DHTML/VBSCRIPT/ASP/CCS/IIS/DAB/SQLServer

We can and may not use JAVASCRIPT for reason that it would be an advantage to some students in our class.

Below is some code that represents my problem (simplified - the actual code on server side calls a stored procedure on SQL-server ...)


my_asp.asp
---------------------------------------------------------
<%@ Language=VBScript %>
<%
Response.Write(&quot;Hello world&quot;)
%>
---------------------------------------------------------

start.asp (or HTML)
---------------------------------------------------------
<%@ Language=VBScript %>

<HTML>
<HEAD>
<META name=VI60_defaultClientScript content=VBScript>

<SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript>
<!--
Sub button1_onclick
'1: call by clientscript
server.execute(&quot;my_asp.asp&quot;)
End Sub
-->
</SCRIPT>

</HEAD>

<BODY>
<INPUT type=&quot;button&quot; value=&quot;Button&quot; id=button1 name=button1><BR>
<%
'2: call by serverscript
server.execute(&quot;my_asp.asp&quot;)
%>

</BODY>

</HTML>
---------------------------------------------------------

So the '2: call by serverscript is executed
But logically '1: call by clientscript is not executed

Is there a way to work-around this ?
Thank you in advance,
Jurgen
 
Jurgen:

I don't think I understand what your problem is - why can't you use a form?

Forms and their handling is defined by HTML and has in principle nothing to do with JavaScript, so there should be no problem for you to do something like this:

my_asp.asp
---------------------------------------------------------
<%@ Language=VBScript %>
<%
Response.Write(&quot;Hello world&quot;)
%>
---------------------------------------------------------

and the &quot;main program&quot;

start.asp
---------------------------------------------------------
<%@ Language=VBScript %>

<HTML>
<HEAD>
<title>Starting page</title>
</HEAD>
<BODY>
<p>
Press submit and see what happens!
<p>
<form name=&quot;form1&quot; action=&quot;my_asp.asp&quot;>
<INPUT name=&quot;submit&quot; type=submit value=&quot;Submit&quot;>
</form>
</BODY>

</HTML>

If this isn't what you wanted, please excuse me!

DrMaggie ---------
&quot;Those who don't know the mistakes of the past won't be able to enjoy it when they make them again in the future.&quot;
— Leonard McCoy, MD (in Diane Duane's Doctor's Orders)
 
Hi DrMaggie,
Thank you for your quick reply.

First I want to tell you that your solution works.

But the reason why it is not admirable to submit the form is that it takes a refresh of the page (or a new page)
The content on the page in example is quickly rebuilt, but the real page needs much more time to rebuild.

The idea is the following :
A user presses a button, the server executes some SQL-code, but the page remains the same ... (not refreshed)

Mean time, I worked around the problem by putting an iframe on the same page.
The iframe is 'invisible' (i put width & height to 0)
Whenever the user presses the button, i call a function like this :

parent.frames(&quot;asp_execute_frame&quot;).document.location.href = &quot;./Stored_Procedures/update_table.asp?param1=5&param2=7&param3=20&quot;

This 'trick' is not so elegant, but it works. I hope the teacher overlooks this :)

Again thx, and sorry for my not so good english ...
Jurgen
 
Are you sure this is where you should be going?

Server.Execute( ) is normally a rather seldom used feature. It has a number of severe limitations, but is generally used to simulate a dynamic #include directive within an ASP page.

I say simulate because it doesn't work like an #include in many ways. For example variables and Subs or Functions in the ASP page that calls Server.Execute( ) are not visible within the page &quot;called&quot; by Server.Execute( ).

The other thing is that the Server object doesn't exist on the client. The name alone ought to be a clue.

Does your Sub button1_onclick even get invoked? Looks like you have a syntax error to me, there should at least be empty ( ) after the name in your Sub header. But maybe VBScript is forgiving of this - never saw anybody try it.

I'm aware of two technologies to accomplish what you say you want to do. One of these is newer, and involves the use of web services. It requires that you get into DHTML behaviors, XML, SOAP, and a bunch of stuff I suspect is beyond the scope of what you are supposed to be doing.

The other is maybe 1997/98 vintage, and it is called Remote Scripting. This is accomplished via a &quot;helper component&quot; (rsproxy.class) written in Java for portability to Netscrape. The basic idea is that your client-side script can manipulate this client-side object, which makes HTTP requests as directed by your script code and returns the results to your script code as a string. Think of this Java applet as a separate web browser with no page-rendering or other fancy logic: it just knows how to send a request to a web server and grab the results that come back. It happens &quot;behind the back&quot; of your client's browser almost as if they have a second browser window open. There is a detailed overview at if you are curious.

I have to believe that this too is far beyond the scope of your assignment.

I think this is a good time to take what you have to your instructor and ask for guidance. I think you just got off somewhere down a blind alley.

Is it possible you are just supposed to have the client code do a window.navigate(&quot;my_asp.asp&quot;) or something?


Finally, this is an ASP question, not a VBScript question. It should have been addressed to the ASP Forum.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top