martes, 11 de septiembre de 2012

Send excel file to save locally using ASP.NET

Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=reporte.csv");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/excel";
Response.TransmitFile(Server.MapPath("~/exportado/reporte.csv"));
Response.End();

Creating MessageBox using ASP.NET

private void ShowPopUpMsg(string msg)
{
StringBuilder sb = new StringBuilder();
sb.Append("alert('");
sb.Append(msg.Replace("\n", "\\n").Replace("\r", "").Replace("'", "\\'"));
sb.Append("');");
ClientScript.RegisterStartupScript(this.GetType(), "Aviso", sb.ToString(), true);
}