2 Replies - 492 Views - Last Post: 20 June 2019 - 07:08 AM Rate Topic: -----

#1 feelblue   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 42
  • Joined: 27-September 09

Open pdf file inside update panel fail.

Posted 20 June 2019 - 04:01 AM

I have try google and different way.. but still fail to do it. after try for 2 day. need help... thanks.. in advance..


if outside update panel . it work. but when inside update panel it fail.

my current code as below.

html. .aspx
 <asp:UpdatePanel ID="UpdateSubPanel" runat="server">
                 <ContentTemplate>

      <table runat="server" id="table_SubPanel" style="width:100%; background: #F8F8F8;border:0pt solid black;">

        <tr style="border:0pt solid black;" runat="server">
            <td><asp:LinkButton ID="linkbtnAtt1" runat="server" onclick="LinkButton_Click" OnClientClick="window.document.forms[0].target='_Blank';" /></td>
        </tr>
        </table>
    </ContentTemplate>
    </asp:UpdatePanel>



code behind. C#

protected void LinkButton_Click(object sender, EventArgs e)
    {

       
        string TempPage1 = FilePath + TempFileName; //real path
        string TempPage2 = "D:\\123.pdf"; //test path
       
        ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "OpenPage1", "window.open('" + TempPage1 + "', '_blank');", true);
  ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "OpenPage2", "window.open('" + TempPage2 + "', '_blank');", true);
    }






before put in update panel. my code as below. which work.

<asp:LinkButton ID="linkbtnAtt1" runat="server" onclick="LinkButton_Click" OnClientClick="window.document.forms[0].target='_Blank';" />


 protected void LinkButton_Click(object sender, EventArgs e)
    {
        string TempFileName = linkbtnAtt1.Text;
        string FilePath = Server.MapPath("~/Files/");
        WebClient User = new WebClient();
        Byte[] FileBuffer = User.DownloadData(FilePath + TempFileName);
        if (FileBuffer != null)
        {
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-length", FileBuffer.Length.ToString());
            Response.TransmitFile(FilePath + TempFileName);
            Response.BinaryWrite(FileBuffer);
        }
    }



Is This A Good Question/Topic? 0
  • +

Replies To: Open pdf file inside update panel fail.

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15359
  • View blog
  • Posts: 61,590
  • Joined: 12-June 08

Re: Open pdf file inside update panel fail.

Posted 20 June 2019 - 06:47 AM

if outside update panel . it work. but when inside update panel it fail.

What does 'it work' mean here?
Was This Post Helpful? 0
  • +
  • -

#3 feelblue   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 42
  • Joined: 27-September 09

Re: Open pdf file inside update panel fail.

Posted 20 June 2019 - 07:08 AM

View Postmodi123_1, on 20 June 2019 - 06:47 AM, said:

if outside update panel . it work. but when inside update panel it fail.

What does 'it work' mean here?


hi modi, thanks for reply. it work here means, is functioning.
the syntax is functioning. only when inside update panel. it fail
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1