...

View Full Version : Opening file in browser



paul.vickers
10-12-2011, 06:07 PM
Hi guys

I'm a novice when it come to asp.net or all things web developing really. But i managed to create a web page that look into a database and then publishes a link to either a .doc, .pdf, etc

Html link simpley calls something like file://myserver/docs/example.doc

this process works fine in IE8 and IE9 but for some reason it doesn't work in Chrome or Firefox!

does anyone know how to get this to work?

A copy of the code is below



<html>
<head runat="server">
<title>Doc Index</title>
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>

<body>
<img src="/Docindex/name.PNG" width="100" height="50" />
<br><br><br>
<h1 style="text-align:center;"><u>Document Index</u></h1>

<form id="form1" runat="server">
<asp:AccessDataSource
ID="AccessDataSource1" runat="server" DataFile="G:\Builds\goldbuild.mdb"
SelectCommand="SELECT [CustomerID], [LongName] FROM [Customer] ORDER BY [LongName]">
</asp:AccessDataSource>

<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Names="Arial"
style="margin-left: 25%" Font-Size="Small" Text="Customers:"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server" Height="36px"
style="margin-left: 2px" Width="350px" AutoPostBack="True"
DataSourceID="AccessDataSource1" DataTextField="LongName"
DataValueField="CustomerID">
</asp:DropDownList>
</p>
<p>
<asp:AccessDataSource ID="AccessDataSource2" runat="server"
DataFile="G:\Builds\goldbuild.mdb"
SelectCommand="SELECT [DocName], [FileName], [CustomerID] FROM [Documents] WHERE ([CustomerID] = ?)">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="CustomerID"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:AccessDataSource>
</p>
<div align="center">
<asp:DataList ID="DataList1" runat="server"
BorderColor="Black" BorderStyle="Double" BorderWidth="5px" CellPadding="0"
DataKeyField="DocName" DataSourceID="AccessDataSource2" ForeColor="Black"
GridLines="Horizontal" style="margin-left: 0%" Width="60%">
<ItemTemplate>
</div>
<div align="left">
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl='<%# Eval("FileName") %>' Text='<%# Eval("DocName") %>' Font-Size="Small" style="margin-left: 2%"></asp:HyperLink>
<br />
<br />
</ItemTemplate>
<SelectedItemStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
</asp:DataList>
</div>

</p>
</form>
</body>
</html>

jassi.singh
11-09-2011, 07:29 AM
Hi guys

I'm a novice when it come to asp.net or all things web developing really. But i managed to create a web page that look into a database and then publishes a link to either a .doc, .pdf, etc

Html link simpley calls something like file://myserver/docs/example.doc

this process works fine in IE8 and IE9 but for some reason it doesn't work in Chrome or Firefox!

does anyone know how to get this to work?

A copy of the code is below



<html>
<head runat="server">
<title>Doc Index</title>
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>

<body>
<img src="/Docindex/name.PNG" width="100" height="50" />
<br><br><br>
<h1 style="text-align:center;"><u>Document Index</u></h1>

<form id="form1" runat="server">
<asp:AccessDataSource
ID="AccessDataSource1" runat="server" DataFile="G:\Builds\goldbuild.mdb"
SelectCommand="SELECT [CustomerID], [LongName] FROM [Customer] ORDER BY [LongName]">
</asp:AccessDataSource>

<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Names="Arial"
style="margin-left: 25%" Font-Size="Small" Text="Customers:"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server" Height="36px"
style="margin-left: 2px" Width="350px" AutoPostBack="True"
DataSourceID="AccessDataSource1" DataTextField="LongName"
DataValueField="CustomerID">
</asp:DropDownList>
</p>
<p>
<asp:AccessDataSource ID="AccessDataSource2" runat="server"
DataFile="G:\Builds\goldbuild.mdb"
SelectCommand="SELECT [DocName], [FileName], [CustomerID] FROM [Documents] WHERE ([CustomerID] = ?)">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="CustomerID"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:AccessDataSource>
</p>
<div align="center">
<asp:DataList ID="DataList1" runat="server"
BorderColor="Black" BorderStyle="Double" BorderWidth="5px" CellPadding="0"
DataKeyField="DocName" DataSourceID="AccessDataSource2" ForeColor="Black"
GridLines="Horizontal" style="margin-left: 0%" Width="60%">
<ItemTemplate>
</div>
<div align="left">
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl='<%# Eval("FileName") %>' Text='<%# Eval("DocName") %>' Font-Size="Small" style="margin-left: 2%"></asp:HyperLink>
<br />
<br />
</ItemTemplate>
<SelectedItemStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
</asp:DataList>
</div>

</p>
</form>
</body>
</html>


Hello,

Please paste the server side code for file downloading to get more idea

Thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum