Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

button to view file in browser outside of inetpub

Status
Not open for further replies.

hamking01

Programmer
May 30, 2004
238
US
can i have a asp:button to view/open a file in the browser. I can do it with a hyperlink, but i'm trying to do it with a button but can't figure out how. Any help?
 
What type of file? You should just be able to do a response.redirect to it depending on the file type and what you want to do with it.

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
with reponse.redirect it keeps adding a http: in front of my file, when I'm trying to open a file on a different server.

eg. when i response.redirect("\\servername\file.pdf")

url has http:\\servername\file.pdf
 
k, found the issue.

Dim dfdo As New CrystalDecisions.Shared.DiskFileDestinationOptions
Dim szFilename As String
szFilename = "C:\opsFile\adobe\mypdf.pdf"
dfdo.DiskFileName = szFilename
With oRpt
.ExportOptions.ExportDestinationType = CrystalDecisions.[Shared].ExportDestinationType.DiskFile
.ExportOptions.ExportFormatType = CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat
.ExportOptions.DestinationOptions = dfdo
.Export()
End With

Private Sub btnView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnView.Click
Response.Redirect("..\OpsFile\adobe\LogRpt_StatusPlant.pdf")
End Sub

The above code works fine. 1st part of sub writes crystal reports to pdf and writes to location on C: drive. 2nd sub handles btn click to redirect to file (it only works when I create the OpsFile as a virtual directory.

When I change the path of both subs to a different server, eg. \\myserver\adobe\filename, it doesn't work anymore. The 1st sub is within try..catch..finally clauses, but it doesn't return any exceptions. the crystal reports runs in browser but file isn't save to location.

Also tested 2nd sub with response.redirect, but it returns no file found. If I use same file path in "a href" it works fine.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top