VBScript (serverside and client side differences)

Status
Not open for further replies.

E3

Ars Centurion
387
<%@ Language=VBScript %>

<% calldisplaymsgbox %>

<%
sub displaymsgbox
returnvalue = Msgbox ("Unregister successful,return to main page?" ,vbokonly)
if returnvalue = 0 then
Response.Redirect "./link.asp"
end if
End sub
%>


Error Type:
Microsoft VBScript runtime (0x800A0046)
Permission denied: 'Msgbox'
/demo/CloseBid1a.asp, line 46


does this means msgbox only is available on client side?
What exactly does <%@ Language=VBScript %> does? besides being able to to IF/ELSE statements,assign of variables at server side.
 

E3

Ars Centurion
387
<script Language = VBScript>
sub displaymsgbox
returnvalue = Msgbox ("Unregister successful,return to main page?" ,vbokonly)
if returnvalue = 0 then
location.href "./link.asp"
end if
End sub

</Script>

<% call displaymsgbox%>


Error Type:
Microsoft VBScript runtime (0x800A01F4)
Variable is undefined: 'displaymsgbox'
/demo/CloseBid1a.asp, line 42

Probaby, I think can't call the method from serverside.
Anyone has any better alternatives of displaying the messagebox?

Basicaly I have
<% function name
If true then
call displaymsgbox
else
nothing
%>

the function is a stored procedure
 
Looks like you're confused

<%%> <-- runs on the server
<script></script> <-- runs on the client

The two are separate creatures.


If you need dynamic client side code, generate it server side
Code:
response.write "<script Language = VBScript>" & _
  "sub displaymsgbox" & _
  "returnvalue = Msgbox (""Unregister successful,return to main page?"" ,vbokonly)" & _
  "if returnvalue = 0 then" & _
  "location.href "./link.asp" & _
  "end if" & _
  "End sub" & _
  "displaymsgbox" & _
  "</script>"
 

E3

Ars Centurion
387
Originally posted by iljhar:
You can call it from the server side, something like this should work:

Code:
<%if request.form["foo") = "bar" then
 response.write("<script language=""VBScript"">")
 response.write("Call displaymsgbox()")
 response.write("</SCRIPT>")
end if%>

Err, yeah, I didn't read the last line of JJJ's code where it calls the function, heh.


Wow! That works! how did u ever find that out. It solve alot of my redirection progs in my web app. Mainly because I wanted more user interaction and letting the user know whats going on in the background.

Anyway thanks to all the helpful posters that replied to my thread
 
Status
Not open for further replies.