Hi,
I need to open PDF document in new window when i click on linkbutton
in datagrid.For that i have written code as below:
But the problem with this code is that it opens the new window ,but not
loading the pdf.Please let me know how can i solve this issue.
private void grdTest_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if(e.CommandName=="View")
{
LinkButton btn =
e.Item.FindControl("linkView") as LinkButton;
Label lbl=e.Item.FindControl("lblText") as Label ;
sp.DmsID=lbl.Text;
GetPDFDoc(sp);
btn.Attributes.Add("Onclick","window.open('TestDat a.aspx');" +
"return false;");
}
}
Here is the GetPDF function:
public void GetPDFDoc(SearchParams sp)
{
//Tentative tr=new Tentative();
Minute min=new Minute();
MemoryStream pdfStream = new MemoryStream();
pdfStream = min.GetMinuteOrderPdf(sp);
Response.Clear();
Response.Charset = "";
Response.ContentType = "application/pdf";
Response.AddHeader( "content-length", System.Convert.ToString(
pdfStream.Length ) );
Response.BinaryWrite( pdfStream.ToArray() );
Response.End();
}
Thanks,
Vishnu