PostBackUrl cannot work for file link.

A

ABC

I write the code as:
<asp:LinkButton ID="LinkButton2" Text='<%# Eval("Title") %>'
PostBackUrl='file://<%# Eval("path") %>' runat="server"></asp:LinkButton>

But It don't work to download or open file when I clicked.



How should I do?
 
A

ABC

I browsing from the server. no error message showed. When I clicked the
link, no response, no file open or download.

The source code from browser showed as:

<table cellspacing="0" cellpadding="2" border="0"
id="GViewDocumentSearchResult"
style="color:Black;background-color:LightGoldenrodYellow;border-color:Tan;border-width:1px;border-style:solid;width:100%;border-collapse:collapse;">
<tr style="background-color:Tan;font-weight:bold;">
<th scope="col">&nbsp;</th>
</tr><tr>
<td>
<a
id="GViewDocumentSearchResult_ctl02_HyperLink2"
href="file://c:\docs\mcgraw.hill.osborne.media.microsoft.sql.server.2005.new.features.txt"
target="_blank">Table of Contents</a>
(<span
id="GViewDocumentSearchResult_ctl02_LblSize">6942591</span> Bytes)<br />
<span
id="GViewDocumentSearchResult_ctl02_Label2">Back Cover. Get full details on
all the innovative features and benefits available in the upcoming release
of SQL Server 2005. This authoritative guide explains the new and improved
enterprise data management capabilities, developer functions, and business
intelligence tools. Youâ?Tll see how the new release offers enhanced
scalability, availability, and security, as well as ease-of-use. Written by
the Senior Technical Editor of SQL Server Magazine, this is an ideal
resource for decis</span><br />
<a
id="GViewDocumentSearchResult_ctl02_HyperLink1"
href="file://c:\docs\mcgraw.hill.osborne.media.microsoft.sql.server.2005.new.features.txt"
target="_blank">c:\pcmsdocs\mcgraw.hill.osborne.media.microsoft.sql.server.2005.new.features.chm</a><br
/>
</td>
</tr><tr style="background-color:paleGoldenrod;">
<td>
<a
id="GViewDocumentSearchResult_ctl03_HyperLink2"
href="file://c:\docs\oreilly.essential.business.process.modeling.2005.txt"
target="_blank">Y</a>
(<span
id="GViewDocumentSearchResult_ctl03_LblSize">4068714</span> Bytes)<br />
<span
id="GViewDocumentSearchResult_ctl03_Label2">Index. SYMBOL. A. B. C. D. E. F.
G. H. J. K. L. M. N. O. P. Q. R. T. U. V. W. X. Y. abstract processes. 2nd.
abstractProcess attribute. action activity. actions, pi-calculus and.
activities. automated. BPDM and. BPEL and. 3rd. BPML processes and. BPMN
and. BPRI and. branching. canceling. compensation and. dead path
elimination. defined. forking. insurance claims processing example. looping
and. merging conditional paths. milestones and. multiple instances of.
activity control category (WAPI). </span><br />
<a
id="GViewDocumentSearchResult_ctl03_HyperLink1"
href="file://c:\docs\oreilly.essential.business.process.modeling.2005.txt"
target="_blank">c:\pcmsdocs\oreilly.essential.business.process.modeling.aug.2005.chm</a><br
/>
</td>
</tr><tr>
<td>
<a
id="GViewDocumentSearchResult_ctl04_HyperLink2"
href="file://c:\docs\wrox.press.beginning.asp.net.2.0.databases.beta.preview.mar.2005.txt"
target="_blank">untitled</a>
(<span
id="GViewDocumentSearchResult_ctl04_LblSize">6699859</span> Bytes)<br />
<span
id="GViewDocumentSearchResult_ctl04_Label2">Beginning ASP.NET 2.0 Databases
Beta Preview TEAM LinG -Live, Informative, Non-cost and Genuine !. TEAM
LinG -Live, Informative, Non-cost and Genuine !. Beginning ASP.NET 2.0
Databases Beta Preview John Kauffman with Thiru Thangarathinam TEAM
LinG -Live, Informative, Non-cost and Genuine !Beginning ASP.NET 2.0
Databases Beta Preview Published by Wiley Publishing, Inc. 10475 Crosspoint
Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2005 by Wiley
Publishing, Inc. Indianapolis</span><br />
<a
id="GViewDocumentSearchResult_ctl04_HyperLink1"
href="file://c:\docs\wrox.press.beginning.asp.net.2.0.databases.beta.preview.mar.2005.txt"
target="_blank">c:\pcmsdocs\wrox.press.beginning.asp.net.2.0.databases.beta.preview.mar.2005.ebook-ling.pdf</a><br
/>
</td>
</tr>
</table>
 
B

Brock Allen

PostBackUrl is for cross page postbacks. If you want a link to do a download
of a file form your database, I'd suggest writing a handler (say .ashx file)
to do the load from your database. Then all your link needs to be is a standand
<a> to the ashx file.
 
B

Bruce Barker

the binding expression (<%# %>) to be the only value in a attribute, or it
won't be detected as a binding expression and will be treated as a string
value. try:

<asp:LinkButton ID="LinkButton2" Text='<%# Eval("Title") %>'
PostBackUrl='<%# "file://" + Eval("path") %>' runat="server" />

also be sure you call DataBind(), so binding is performed.

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top