Javascript: How to cancel leaving page without saving

Preparing the javascript:
string jscript = "var needToSave= false;" +
"window.onbeforeunload = confirmExit;" +
"function confirmExit(){" +
"if (needToSave){" +
"return 'Are you sure you want to leave the page without saving?';" +
"}" +
"}";

Registering the script - safe for ajax:

ScriptManager smgr = ScriptManager.GetCurrent(Page);
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "temp", "", false);

On every field that changes the data and requires saving put:
control.Attributes.Add("onkeydown","javascript: needToSave=true;")

on the button that make save postback add:
control.Attributes.Add("onclick","javascript: needToSave=false;")

Page Cannot Be Found Issue on IIS 6 on Windows 2003

Also:
HTTP 404 - File not found

First of all be sure that the default document list contains the page you are requesting (IIS -> Server Node -> Site node -> right mose click -> Properties -> Documents
Also set the necessary permission to the web folder (NETWORK SERVICE must have read/write rights)
Check if the asp.net status is allowed (IIS -> Server Node -> Web Service Extensions -> Asp.net must be allowed). This can be done during the installation of IIS.

ASP.NET Export content to Excel files.

The most common problem during exporting page content to an excel file is the following exception: RegisterForEventValidation can only be called during Render();
The only thing you need to do is to set enableEventValidation ="false" in web.config (affects all your pages) or in the head page line.

If you want to render a control into an excel file (using HTML representation) the VerifyRenderingInServerForm() method must be overridden.

public override void VerifyRenderingInServerForm(Control control){}

This confirms that an HtmlForm control is already rendered.

... and the example - rendering existing gridview control into a xls file:
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=file.xls");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter(); ;
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
htmlWrite.Write("text text");
htmlWrite.WriteBreak();
GridView1.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();