Hi everyone,
I am trying to error trap for an invalid file name. When an invalid
file name is given, a message box saying "Cannot find
'file:///F:/Invoice/111.tif'. Make sure the path of Internet address is
correct.".
How can I go about redirecting to another page should an invalid file
name be given? Or can I run some other code to go look up in a database
the location of the file?
Here is the code I am working with...
Protected Sub SearchButton_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles SearchButton.Click
Dim ImageString As String
Select Case ImageTypeRadioButtonList.SelectedItem.ToString
Case "AWB"
ImageString = "<script>window.open('F:/AWB/" +
ImageTextBox.Text + ".tif', '_blank');</script>"
Case "Invoice"
'ImageString = "<script>window.open('F:/Invoice/" +
ImageTextBox.Text + ".tif', '_blank');</script>"
Case "Voucher"
ImageString = "<script>window.open('F:/Voucher/" +
ImageTextBox.Text + ".tif', '_blank');</script>"
End Select
ImageTextBox.Text = ""
ImageTextBox.Focus()
Try
Response.Write(ImageString)
Response.Write("<script
language='javascript'>history.back()</script>")
Catch ex As Exception
Response.Redirect("http://www.google.com")
Finally
End Try
End Sub
Thanks for your help in this matter.
j.t.w 4 1819
You won't be able to catch it on the code behind because it is trying to
open a file on the client. You'd need to wrap the code in a try/catch script
block. The basic syntax is the same but the exception code would need to be
placed inside the script tags.
You do realize that according to your code, you are trying to open a file on
the user's desktop and not on the server right?
--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]
[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------
<j.***@juno.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
Hi everyone,
I am trying to error trap for an invalid file name. When an invalid
file name is given, a message box saying "Cannot find
'file:///F:/Invoice/111.tif'. Make sure the path of Internet address is
correct.".
How can I go about redirecting to another page should an invalid file
name be given? Or can I run some other code to go look up in a database
the location of the file?
Here is the code I am working with...
Protected Sub SearchButton_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles SearchButton.Click
Dim ImageString As String
Select Case ImageTypeRadioButtonList.SelectedItem.ToString
Case "AWB"
ImageString = "<script>window.open('F:/AWB/" +
ImageTextBox.Text + ".tif', '_blank');</script>"
Case "Invoice"
'ImageString = "<script>window.open('F:/Invoice/" +
ImageTextBox.Text + ".tif', '_blank');</script>"
Case "Voucher"
ImageString = "<script>window.open('F:/Voucher/" +
ImageTextBox.Text + ".tif', '_blank');</script>"
End Select
ImageTextBox.Text = ""
ImageTextBox.Focus()
Try
Response.Write(ImageString)
Response.Write("<script
language='javascript'>history.back()</script>")
Catch ex As Exception
Response.Redirect("http://www.google.com")
Finally
End Try
End Sub
Thanks for your help in this matter.
j.t.w
you are doing the catch on the server, when the error in on the client. as
its a page not found error, there is no way to catch it.
-- bruce (sqlwork.com)
<j.***@juno.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
Hi everyone,
I am trying to error trap for an invalid file name. When an invalid
file name is given, a message box saying "Cannot find
'file:///F:/Invoice/111.tif'. Make sure the path of Internet address is
correct.".
How can I go about redirecting to another page should an invalid file
name be given? Or can I run some other code to go look up in a database
the location of the file?
Here is the code I am working with...
Protected Sub SearchButton_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles SearchButton.Click
Dim ImageString As String
Select Case ImageTypeRadioButtonList.SelectedItem.ToString
Case "AWB"
ImageString = "<script>window.open('F:/AWB/" +
ImageTextBox.Text + ".tif', '_blank');</script>"
Case "Invoice"
'ImageString = "<script>window.open('F:/Invoice/" +
ImageTextBox.Text + ".tif', '_blank');</script>"
Case "Voucher"
ImageString = "<script>window.open('F:/Voucher/" +
ImageTextBox.Text + ".tif', '_blank');</script>"
End Select
ImageTextBox.Text = ""
ImageTextBox.Focus()
Try
Response.Write(ImageString)
Response.Write("<script
language='javascript'>history.back()</script>")
Catch ex As Exception
Response.Redirect("http://www.google.com")
Finally
End Try
End Sub
Thanks for your help in this matter.
j.t.w
Thanks for your reply.
This page is running on our Intranet, so I guess that's why it was
running. I've changed it so that the page retrieves the file from the
server. Thanks for the heads up.
Now it reads...
ImageString = "<script>window.open('file://MyServer/AWB/" +
ImageTextBox.Text + ".tif', '_blank');</script>"
Can you show me how to place the code between script tags? I've tried a
couple of different ways but it doesn't seem to work.
Thanks,
j.t.w
Alvin Bruney [MVP] wrote:
You won't be able to catch it on the code behind because it is trying to
open a file on the client. You'd need to wrap the code in a try/catch script
block. The basic syntax is the same but the exception code would need to be
placed inside the script tags.
You do realize that according to your code, you are trying to open a file on
the user's desktop and not on the server right?
--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]
[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------
<j.***@juno.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
Hi everyone,
I am trying to error trap for an invalid file name. When an invalid
file name is given, a message box saying "Cannot find
'file:///F:/Invoice/111.tif'. Make sure the path of Internet address is
correct.".
How can I go about redirecting to another page should an invalid file
name be given? Or can I run some other code to go look up in a database
the location of the file?
Here is the code I am working with...
Protected Sub SearchButton_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles SearchButton.Click
Dim ImageString As String
Select Case ImageTypeRadioButtonList.SelectedItem.ToString
Case "AWB"
ImageString = "<script>window.open('F:/AWB/" +
ImageTextBox.Text + ".tif', '_blank');</script>"
Case "Invoice"
'ImageString = "<script>window.open('F:/Invoice/" +
ImageTextBox.Text + ".tif', '_blank');</script>"
Case "Voucher"
ImageString = "<script>window.open('F:/Voucher/" +
ImageTextBox.Text + ".tif', '_blank');</script>"
End Select
ImageTextBox.Text = ""
ImageTextBox.Focus()
Try
Response.Write(ImageString)
Response.Write("<script
language='javascript'>history.back()</script>")
Catch ex As Exception
Response.Redirect("http://www.google.com")
Finally
End Try
End Sub
Thanks for your help in this matter.
j.t.w
If the file is on the server, use the code behind and the file exist method
to determine if the file is available. I think that's what you want.
Construct your script appropriately.
--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]
[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------
"bruce barker (sqlwork.com)" <b_*************************@sqlwork.comwrote
in message news:uJ**************@TK2MSFTNGP03.phx.gbl...
you are doing the catch on the server, when the error in on the client. as
its a page not found error, there is no way to catch it.
-- bruce (sqlwork.com)
<j.***@juno.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
>Hi everyone,
I am trying to error trap for an invalid file name. When an invalid file name is given, a message box saying "Cannot find 'file:///F:/Invoice/111.tif'. Make sure the path of Internet address is correct.".
How can I go about redirecting to another page should an invalid file name be given? Or can I run some other code to go look up in a database the location of the file?
Here is the code I am working with...
Protected Sub SearchButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SearchButton.Click Dim ImageString As String
Select Case ImageTypeRadioButtonList.SelectedItem.ToString Case "AWB" ImageString = "<script>window.open('F:/AWB/" + ImageTextBox.Text + ".tif', '_blank');</script>" Case "Invoice" 'ImageString = "<script>window.open('F:/Invoice/" + ImageTextBox.Text + ".tif', '_blank');</script>" Case "Voucher" ImageString = "<script>window.open('F:/Voucher/" + ImageTextBox.Text + ".tif', '_blank');</script>" End Select ImageTextBox.Text = "" ImageTextBox.Focus()
Try Response.Write(ImageString) Response.Write("<script language='javascript'>history.back()</script>") Catch ex As Exception Response.Redirect("http://www.google.com") Finally
End Try End Sub
Thanks for your help in this matter. j.t.w This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Roger Redford |
last post by:
Dear experts,
I'm trying to learn java on my own. I picked up a
sample online, but it is not compiling right:
------------------------------------------------
import java.io.*;
|
by: kaeli |
last post by:
Hey all,
I'd like to start using the try/catch construct in some scripts. Older
browsers don't support this. What's the best way to test for support for this
construct so it doesn't kill...
|
by: Andrew Schepler |
last post by:
When compiled with Visual C++ .NET 2003 (only), the program below aborts as though no matching catch clause is present. If the copy constructor of A is made public, it successfully catches the...
|
by: Tiraman |
last post by:
Hi ,
I am using allot the try catch in my code and the question is
if it is good ?
it will decrease my performance ?
one more question
|
by: Keith Kowalski |
last post by:
I anm opening up a text file reading the lines of the file that refer to a
tif image in that file, If the tif image does not exist I need it to send an
email stating that the file doesn't exist...
|
by: cj |
last post by:
Another wish of mine. I wish there was a way in the Try Catch structure
to say if there wasn't an error to do something. Like an else
statement. Try Catch Else Finally.
Also because I...
|
by: garyusenet |
last post by:
Hi I'm using the following code which is finally working.
Public Class Form1
Shared ActElement As Object
Shared ActFields As DataSet
Public Sub SetActElement()
Dim objApp As New Object
|
by: Bit byte |
last post by:
Is there any way of retrievieng error information (say, from a 'global'
or system wide) error object - when you are in a catch all statement block?
Sometimes it cannot be helped, when something...
|
by: Michael C |
last post by:
I'm writing an app on the PDA using C# with .net 1.1. It is all working well
except in some cases a try catch is simply ignored and a totally different
error is returned. I've got code like below...
|
by: cj |
last post by:
my old code
Try
Dim sw As New System.io.StreamWriter(fileName, True)
sw.WriteLine(strToWrite)
sw.Close()
Catch
End Try
my new code
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |