Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can try something like this, open new popup.aspx page with filename as queryparam. In the new popup page page_load, read the content and write it to the browser</p> <pre><code>&lt;asp:GridView ID="FilterGrid" runat="server" AutoGenerateColumns="False" &gt; &lt;Columns&gt; &lt;asp:TemplateField HeaderText="FileName" &gt; &lt;ItemTemplate&gt; &lt;asp:HyperLink ID="ActionHyperLink" runat="server" Text='&lt;%# Eval("FileName") %&gt;' NavigateUrl='&lt;%# Eval("FileName","~/FilePopUp.aspx?filename={0}") %&gt;' Target="_blank" /&gt; &lt;asp:HyperLink ID="HyperLink2" runat="server" Text='&lt;%# Eval("FileName") %&gt;' NavigateUrl='&lt;%# String.Format("filepopup.aspx?filename={0}", Eval("filename")) %&gt;' onclick="javascript:w= window.open(this.href,'DownloadFile','left=20,top=20,width=500,height=500,toolbar=0,resizable=0');return false;"&gt;&lt;/asp:HyperLink&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; </code></pre> <p>The pageload of popup</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["filename"] != null) { //Get the content from database byte[] fileContent = ....; Response.Clear(); string doctype = ...; if (doctype == ".doc") { Response.ContentType = "application/msword"; } else if (doctype == ".pdf") { Response.ContentType = "application/pdf"; } else if (doctype == ".xls") { Response.ContentType = "application/vnd.ms-excel"; } else if (doctype == ".xlsx") { Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; } Response.BinaryWrite(fileContent); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload