MsgBox error


B

Bob L

I've inserted a MsgBox in some VBScript on line 12 of an .asp page and get
the following error:

Microsoft VBScript runtime error '800a0046'
Permission denied: 'MsgBox'

/default.asp, line 12

The script processes a form and other than this problem with MsgBox, the
script works fine. I've Googled the error but so far haven't found an
answer that applies. Any idea what the problem might be and how I can get
it to work?
 
Ad

Advertisements

B

Bob Barrows [MVP]

Bob said:
I've inserted a MsgBox in some VBScript on line 12 of an .asp page
and get the following error:

Microsoft VBScript runtime error '800a0046'
Permission denied: 'MsgBox'

/default.asp, line 12

The script processes a form and other than this problem with MsgBox,
the script works fine. I've Googled the error but so far haven't
found an answer that applies. Any idea what the problem might be and
how I can get it to work?
You can't use MsgBox in server-side code. Think about it. Who will be at the
server's monitor waiting to click the OK button?
 
B

Bob L

That makes sense. Thanks.

Bob Barrows said:
You can't use MsgBox in server-side code. Think about it. Who will be at
the
server's monitor waiting to click the OK button?
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
 
B

Bob L

As a followup question, is there a way I can code in MsgBox in the .asp page
so that it is processed on the client computer after being process by the
server?
 
B

Bob Barrows [MVP]

Somebody posted an example a while back of response.writing a client-side
script block containing a statement that would be executed in the
window_onload event. Something like this:

<%="<script type='text/javascript'>msgbox 'some message'</script>"%>
 
J

Jess

Here's what works for me

http://www.codingforums.com/archive/index.php/t-51986
You are using a response.Redirect in the same if then statement which
basically cancels the javascript alert even though the alert is listed above
the redirect.

If this is page is referenced from a form on a different page and that is
what you are redirecting to then you have multiple options.
1) You can rewrite it so that the the form and the form handler are on the
same page. Basically it will then do a postback to itself so then you can do
the alert on eof like you are doing or you can spell out an error on the page
in case the user has a non javascript enabled browser.

And if it isnt the same page being redirected to then you have two more
options
2) You can add a delayed redirect using javascript or a refresh metatag
3)redirect to the other page and pass a variable along with it. Then on the
redirected page use an If/Then statement looking for that variable. Then if
it is true the javascript alert is triggered. like so

on Refering page
if recordset.eof then
recordset.close
Set recordset= Nothing
Response.Redirect "StaffingReview.asp?1"
(IF Multiple send back - Response.Redirect"Staf.asp?a=1&b=2"
End If

On StaffingReview.asp
dim e
e = Request.Querystring
e = Request.Querystring("a") - for multiple
If e = 1 Then
Response.write("<script type=""text/javascript"">alert(""What is the
employee's ID Number? If unavailable enter N/A. Re-select your employee
before filling out the rest of the form."");</script>")
End If

vBulletin v3.0.0, Copyright ©2000-2005, Jelsoft Enterprises Ltd.
 
Ad

Advertisements

B

Bob Barrows [MVP]

Bob said:
Somebody posted an example a while back of response.writing a
client-side script block containing a statement that would be
executed in the window_onload event. Something like this:

<%="<script type='text/javascript'>msgbox 'some message'</script>"%>
Oops, that should have been:
type='text/vbscript'
 
Ad

Advertisements

E

Evertjan.

Bob Barrows [MVP] wrote on 07 dec 2005 in
microsoft.public.inetserver.asp.general:
Oops, that should have been:
type='text/vbscript'

and then double quoted strings should be used:

<%="<script type='text/vbscript'>msgbox "some message"</script>"%>

IE only, this clientside vbs.

============================

A problem is, that a subsequent

<span onclick='this.innerHTML+="D"'>ABC</span>

will fail, because the onclick will expect vbs, not js.
 

Top