| Author |
Topic Search Topic Options
|
neotrix
Mod Builder Group
Joined: 09 November 2003
Location: Pakistan
Status: Offline
Points: 433
|
Post Options
Thanks(0)
Quote Reply
Topic: onError Command in ASP ?!? Posted: 02 May 2004 at 7:26am |
Hello All,
I wanted to ask is there any onError Kindov a command in asp ?
For example, if i try to open a file using server.execute and the file is not there, could there be a command with the help of which i can write a custom error message ?
i just wrote
Server.Execute(songlyrics) onError(Server.Execute("error.asp"))
|
I dont think this works, is there any command that may do this ?thanks in advance.
|
|
|
 |
Semikolon
Senior Member
Joined: 09 September 2003
Location: Norway
Status: Offline
Points: 1718
|
Post Options
Thanks(0)
Quote Reply
Posted: 02 May 2004 at 8:09am |
<%
On Error Resume Next 'Resume to the next line if error
... ... ...
If Err.Number <> 0 Then 'If there is an error
... ... ... 'Action to perform if there is an error
End If
%>
|
|
 |
neotrix
Mod Builder Group
Joined: 09 November 2003
Location: Pakistan
Status: Offline
Points: 433
|
Post Options
Thanks(0)
Quote Reply
Posted: 02 May 2004 at 8:29am |
ThaaaankkkkkkkkkkYouuuuuuuuuuuu
^_^
|
|
|
 |
dpyers
Senior Member
Joined: 12 May 2003
Status: Offline
Points: 3937
|
Post Options
Thanks(0)
Quote Reply
Posted: 02 May 2004 at 1:55pm |
|
Won't work. Sever executes and includes are resolved when the asp page loads - not when the script executes.
|
Lead me not into temptation... I know the short cut, follow me.
|
 |
Semikolon
Senior Member
Joined: 09 September 2003
Location: Norway
Status: Offline
Points: 1718
|
Post Options
Thanks(0)
Quote Reply
Posted: 02 May 2004 at 1:59pm |
|
for includes it wont work, but with server.execute it works fine
ServerSideIncludes is Pre-processing, but Server.* Commands is not.
|
 |
Mart
Senior Member
Joined: 30 November 2002
Status: Offline
Points: 2304
|
Post Options
Thanks(0)
Quote Reply
Posted: 02 May 2004 at 5:58pm |
dpyers wrote:
Try this.
Create 2 asp pages - calling.asp and called.asp.
In calling.asp, paste this code...
<% 'On Error Resume Next Server.Execute("called.asp") If Err.Number <> 0 then response.write Err.Number & " - " & Err.Description & "<BR>" else response.write "<BR>calling program ran ok<BR>" End If %> |
In called.asp, paste this code...
<% response.write "<BR>Written by the program invoked by sever.execute <BR>" %> |
Run calling.asp, and you'll see the response written by called.asp
Now change the file name used in calling.asp's server.execute statement to something else that doesn't exist - e.g. xxx.asp and rerun calling.asp.
You'll get a page load error for calling.asp.
|
In calling.asp you have commented out On Error Resume next...
Change line 1 from
'On Error Resume Next
To
On Error Resume Next
|
 |
Semikolon
Senior Member
Joined: 09 September 2003
Location: Norway
Status: Offline
Points: 1718
|
Post Options
Thanks(0)
Quote Reply
Posted: 02 May 2004 at 5:59pm |
|
why did you comment On Error?
if it was a typo, what server are you running?
|
 |
dpyers
Senior Member
Joined: 12 May 2003
Status: Offline
Points: 3937
|
Post Options
Thanks(0)
Quote Reply
Posted: 02 May 2004 at 6:02pm |
<STUPID action='smacks head on forehead'>
Doh! you're right. no wonder it didn't work.
</STUPID>
|
Lead me not into temptation... I know the short cut, follow me.
|
 |