MsgBox error

Discussion in 'ASP General' started by Bob L, Dec 7, 2005.

  1. Bob L

    Bob L Guest

    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?
    Bob L, Dec 7, 2005
    1. Advertisements

  2. 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?
    Bob Barrows [MVP], Dec 7, 2005
    1. Advertisements

  3. Bob L

    Bob L Guest

    That makes sense. Thanks.

    Bob L, Dec 7, 2005
  4. Bob L

    Bob L Guest

    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
    Bob L, Dec 7, 2005
  5. 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>"%>
    Bob Barrows [MVP], Dec 7, 2005
  6. Bob L

    Jess Guest

    Here's what works for me
    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
    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
    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.
    Jess, Dec 7, 2005
  7. Oops, that should have been:
    Bob Barrows [MVP], Dec 7, 2005
  8. Bob L

    Evertjan. Guest

    Bob Barrows [MVP] wrote on 07 dec 2005 in
    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.
    Evertjan., Dec 7, 2005
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.