Monday, February 13, 2012

Open new window in ASP.NET

----------------------------------------------------
Page.ClientScript.RegisterStartupScript(this.GetType(), "ale", "window.open('http://www.google.com',null,'height=600,width=800');", true);

Class File : Export.cs

---------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using System.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;

///
/// Summary description for Export
///

public class Export
{
string attachment;

public Export()
{

}
public void Exportfn(GridView grdvw)
{
//Dataread drgrd = new Dataread();
//drgrd.fileread(sqlquery, grdvw);
attachment = "attachment; filename=AVAYA.xls";
System.Web.HttpContext.Current.Response.ClearContent();
System.Web.HttpContext.Current.Response.AddHeader("content-disposition", attachment);
System.Web.HttpContext.Current.Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
grdvw.RenderControl(htw);
System.Web.HttpContext.Current.Response.Write(sw.ToString());
System.Web.HttpContext.Current.Response.End();

}



}