ViewDownload

Last Reply on Jan 13, 2014 06:06 AM By Mudassar

Posted on Jan 13, 2014 04:46 AM

I would Like to ask that i am having a problem if i click on a hyperlink in a gridview for view purpose in a _blank window it work well for images but for file like .docx .pdf .ppt it download those files rather than opening them in a window what would be problem?? what should i do??

I'm using this code in aspx file!!

<asp:TemplateField HeaderText="List of Files">
<ItemTemplate>
<asp:HyperLink ID="Hyp1" Target="_blank" runat="server" Width="100px" Text='<%#Eval("Bui_File")%>' NavigateUrl='<%#Eval("Bui_File")%>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>

Results 1 - 5 of 6 12
Posted on Jan 13, 2014 04:46 AM

Remove

 Target="_blank

 


Posted on Jan 13, 2014 04:54 AM

Problem isn't arising in the formate sir actually our content isn't OPENING UP FOR VIEW PURPOSE FOR FILES it's working well for images view!!


Posted on Jan 13, 2014 05:03 AM

Files cannot be viewed in browser

 


Posted on Jan 13, 2014 05:32 AM

I have Tested this Sample and its running according to your requirement but in IE its getting download if i cick on the name of file.

HTML:

<form id="form1" runat="server">
    <div>
        <asp:GridView ID="gvDemo2" runat="server" AutoGenerateColumns="false">
            <Columns>
                <asp:BoundField DataField="FileId" HeaderText="Id" ItemStyle-Width="100" />
                <asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-Width="100" />
                <asp:TemplateField HeaderText="List of Files">
                    <ItemTemplate>
                        <asp:HyperLink ID="Hyp1" Target="_blank" runat="server" Width="100px" Text='<%#Eval("Name")%>'
                            NavigateUrl='<%#Eval("Path")%>'></asp:HyperLink>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
    </div>
    </form>

C#:

protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            this.PopulateGrid2();
        }
    }

    private void PopulateGrid2()
    {
        DataTable dt2 = new DataTable();
        dt2.Columns.AddRange(new DataColumn[3]{  
                            new DataColumn("FileId", typeof(int)),
                            new DataColumn("Name", typeof(string)),
                            new DataColumn("Path", typeof(string))});
        dt2.Rows.Add(1, "Jake", "Files/Doc1.pdf");
        
        this.gvDemo2.DataSource = dt2;
        this.gvDemo2.DataBind();

    }

Which browser you are using.


Posted on Jan 13, 2014 05:57 AM

Google!! And yeah it's working for images but as far  as any file is concerned whether it's an empty doc it's simply getting downloaded instead of opening for view purpose in a new window!! Am i clear sir?? Tell me solution for this problem