Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 5th, 2005, 04:39 PM
Authorized User
 
Join Date: Jun 2003
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default linkbutton control

When I set a hyperlink with this control pointing to a file on the server it fails to find the file except when the page is run from the server. Here is the snippet

<asp:LinkButton id="LinkButton11" runat="server" OnClick="LinkButton11_Click">Open File</asp:LinkButton>

The code behind is this

Public Sub LinkButton11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton12.Click

Dim frame1 As HtmlControl = CType(Me.FindControl("iframe1"), HtmlControl)
frame1.Attributes("src") = "d:\Data\Issues\Ext Nos.pdf"

End Sub

I would be grateful for any ideas.

thanks

jake
 
Old December 6th, 2005, 02:30 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

If I'm browsing your web application from my computer (which doesn't have a D: drive), how will my computer ever find "d:\Data\Issues\Ext Nos.pdf"? As far as my browser is concerned, it is looking for that file locally.

You'll need to build a page that takes the desired file name as a querystring argument (viewfile.aspx?file=d:\Data\Issues\Ext Nos.pdf) and reads that file and feeds back the binary data of that file. The only other option is to put the files in a disk location that is accessible thru your web server. Then you can provide the browser the web relative address to the file. For example:

1. Either put the files in a folder of the web application, or create a virtual directory that points to the server's physical location of those files:
   Virtual directory in the root of the web server called "data" that points to "D:\data" on the web server.

2. Change your code to reflect the virtual location created in step 1:
   frame1.Attributes("src") = "/data/Issues/Ext Nos.pdf"




-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Bind Two Variables to LinkButton Control cyberstore05 .NET Framework 2.0 1 October 31st, 2008 02:50 AM
LinkButton PostBack handler in custom control Ozzy Bongo BOOK: Professional ASP.NET 2.0 Server Control and Component Development ISBN: 978-0-471-79350-2 0 July 24th, 2008 07:55 AM
WebControls.LinkButton Ric_H ASP.NET 2.0 Basics 1 January 28th, 2006 08:00 AM
linkbutton Beulah VS.NET 2002/2003 3 October 10th, 2005 05:00 PM
LinkButton List Control bmains ASP.NET 1.0 and 1.1 Professional 1 February 27th, 2004 09:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.