Posts

Showing posts from August, 2008

To provide file download Facility in ASP.Net

Image
To provide file download facility to use in from the website the following code need to be done in the button click event protected void Button1_Click(object sender, EventArgs e) { string path = Server.MapPath("html-character-entities-cheat-sheet.pdf"); string name = System.IO.Path.GetFileName(path); Response.AppendHeader("content-disposition","attachment; filename=" + name); Response.ContentType = "Application/pdf"; Response.WriteFile(path); Response.End(); }

To Avoid Popup Blocker to open Pop up from website.

The Following code will used to open popup window and the popup blocker will not block it. Code Of The Parent Page of Popup <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestPopupBlocker.aspx.cs" Inherits="TestPopupBlocker" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" &gt ; <html xmlns=" http://www.w3.org/1999/xhtml " > <head runat="server"> <title>Untitled Page</title> <script language ="javascript"> function getAjaxXml() { var xml; if(document.all) { //IE xml = new ActiveXObject("Microsoft.XMLHTTP"); } else { //FF,Opera,NN