Discussion Locked

Asp question

0 helpful
13 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
When we write VBScript in ASP why does MsgBox not work?

13 replies

by bowjangles

MsgBox does not work because it is a command for Visual Basic language. VBScript is a scripting language with simular syntax to VB but not identical. Im not sure how to get a message box in VBScript but that is why it wont work.

by peyison

The code you write for ASP is server side - that is, it is read and processed by the server. Once the ASP is processed by the server, the HTML generated is returned to the client (the browser). So by the time the browser gets the page, all of the ASP code has already been processed.

Msgbox is a client side command. It needs to be in the page that is processed by the browser (after all of the ASP has been processed). The server doesn't know what to do with Msgbox. You could use client side VBScript to call Msgbox, but you are probably better off using JavaScript for client side code, since more browsers understand JavaScript than VBScript. The JavaScript command is alert().

Hope this helps.

by roc180

Just a side note if you are using VBscript
alert("Some text")
will also work

Good Luck
Neal Martinelli

by juanja

I am sure you have been using ASP and VBScript for some time now. The answer is simple. When you write something like this:

<% msgbox("Alert") %>

Where do you think the script is trying to display the message box? in the user's monitor? WRONG,it tries to display it in the server's monitor, so you will get a "Permission Denied" because the script is executed in the server.

On the other hand, if you try something like this:

<% for a=1 to 2 %>

by rsv

Hi,
The ASP file will be executed on the server.
The code you write for ASP is server side - that is, it is read and processed by the server. Once the ASP is processed by the server, the HTML text stream generated is returned to the client (the browser). So by the time the browser gets the page, all of the ASP code has already been processed.
Msgbox is a client side command. It needs to be in the page that is processed by the browser (after all of the ASP has been processed). The server doesn't know what to do with Msgbox. You could use client side VBScript to call Msgbox, but you are probably better off using JavaScript for client side code, since more browsers understand JavaScript than VBScript. The JavaScript command is alert().
Maybe this will help you.

This discussion is closed to new replies.