Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Open PDF in new windowOpen PDF in new window
Previous
 
Next
New Post
7/14/2006 1:43 PM
 

I would like to have a datagrid with a link for each row that would allow the user to open a pdf in a new window.

I created the an asp:hyperlink column with target="_blank" and in the new page I added the following content in the page load. The result is nothing. Nothing is presented on the scren.

How can I have a page that only opens a pdf? Can someone help?

           Response.Clear();
                string pdfPath = Config.GetSetting("VirtualDirectoryPDFs").ToString() + "\\";

                if (Request.Params["filename"] != null)
                {
                    string file = pdfPath + Request.Params["filename"].ToString();

                    if (File.Exists(file))
                    {
                        Response.ContentType = "application/pdf";
                        FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read);
                        long fileSize = fs.Length;
                        byte[] bytes = new byte[fileSize];
                        fs.Read(bytes, 0, (int)fileSize);
                        fs.Close();
                        Response.OutputStream.Write(bytes, 0, (int)fileSize);

                    }                     
                }      
           
                Response.End();

 

THX

 
New Post
7/14/2006 2:11 PM
 

  I do a very similar thing at one of my sites.  However,  I have Flush and Close the OutPutStream before call the Respone.End.  So something like

    Response.ContentType = "application/pdf";
    FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read);
    long fileSize = fs.Length;
    byte[] bytes = new byte[fileSize];
    fs.Read(bytes, 0, (int)fileSize);
    fs.Close();
    Response.OutputStream.Write(bytes, 0, (int)fileSize);
     Response.OutputStream.Flush();
     Response.OutputStream.Close();

 Hope that helps.

 Paul.
 www.tressleworks.ca

 

 
New Post
3/23/2007 12:46 PM
 
I'm trying to do the same thing. This has worked for me in the past outside dnn. But I get an error  if I  use the flush and close as above.It looks like the compression functionality is getting upset.

Is there a solution for the current version of dnn?

Phil
 
New Post
3/27/2007 6:50 AM
 

Hmm, it's quiet in here isn't it?

I'm fairly new to dnn and I can't seem to find a useful help resource. Am I asking questions in the wrong place perhaps.

Phil

 
New Post
3/27/2007 11:19 AM
 
What error are you getting if you do the flush/close? Have you tried adding your page to the excluded paths in the compression settings?
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Open PDF in new windowOpen PDF in new window


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out