Link to home
Start Free TrialLog in
Avatar of swinslow
swinslowFlag for United States of America

asked on

Permission denied: 'MsgBox'

I have an error check that if someone leaves a required filed blank it sends you back to the previous page to fill it out. I usually just use an html message. But I am trying to do a message box.
Here is the code:
<%
'Error Message
if Request.QueryString("Error") <> "" then
     MsgBox "Please enter your measured time."
end if
%>

When I test it I get the following error:

Error Type:
Microsoft VBScript runtime (0x800A0046)
Permission denied: 'MsgBox'
/InfoPage/IS/PBLI/PBLIForm2.asp, line 67


I am Running Windows 2000 Advanced Server, IIS5.

What does that error mean? How do I fix it?
Avatar of ukorep
ukorep

I dont think Msgbox works here in asp. Try sending an laert message using Javascript.


function validater()
  {
     if (document.fidelity.loginid.value=="")
     {
          alert("Please enter a Value For Login ID")
          document.fidelity.loginid.focus();
          document.fidelity.loginid.select();
          return false;
     }
}

You call this function on the submit of the button.

<FORM Name="form" action="/form/default.asp" method="get" onsubmit = "return validater();">


ukorep
ASP runs on server side. You can not do a server side msgbox. Only client side is possible. On the server side you can write Response.write "Error is = ".
May be you can send the value to the client and use client side msgbox/alert


Myasp.asp
<% Erroris= Request("myError") %>

<script language="JavaScript">
alert("Error is "+<%=erroris%>)
</script>
ASKER CERTIFIED SOLUTION
Avatar of ukorep
ukorep

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You should create error resonse text on the asp that is recognizing the error and send it back to the previous page.  If the previous page is an asp page, you can capture the error like jitganguly mentioned and then throw up a msgbox in the window_onload() event.

The best way is to capture and flag errors for all the form fields before you leave the page.  If you need to do database lookups to determine if some form entries are incorrect, using remote scripting works very well because then you don't have to leave the client page and can send the error information back and pop up a msgbox on the client page without having to worry about losing the form information.

I have sample code for remote scripting error checking and msgbox'ing if you would like - it'll cost you points though. :)
Avatar of Michel Sakr
As already said it can't be done server side so Change your code part to client side:

<%
'Error Message
if Request.QueryString("Error") <> "" then
%>
<script language = Javascript>
   alert("Please enter your measured time")
 </script>
<%
end if
%>
Avatar of swinslow

ASKER

I was able to figure it out. I am accepting your answer, because it is the closest to what I did.

Here is what I ended up using and it works great.

<%
'Error Message
if Request.QueryString("Error") <> "" then
%>
<SCRIPT LANGUAGE="VBScript">
     msgbox "Please enter your measured time.",vbexclamation+vbApplicationModal
</script>
<%
end if
%>
Just for info:

I have tried and we can do a server side msgbox using vbscript.

The only thing we have to do is place the code between

<script language="vbscript">
</script>

and not the delimeters <% %>

try this and it works.

< INPUT TYPE="BUTTON" NAME="button0" VALUE="Click Here!" > 

< SCRIPT LANGUAGE="VBScript" > 
Sub button0_onclick
  MsgBox "Please Click OK"
End Sub
< /SCRIPT > 

Thanks
ukorep



ukorep,
When you do use a script tag it is client side and not the server side. All the server side staff is done using <%%>
jitganguly - you can do server side like so:
<script language=vbscript runat=server>
...
</script>
right psstarkey,
but if you look at his code he didn't specify that.
Is it by default Server ?