Saturday, January 31, 2009

Send file to browser

private void SendFile(string fileText, string fileName, string contentType) {
  this.Response.Clear();
  this.Response.AddHeader("content-disposition", "attachment;filename=" + fileName);
  this.Response.ContentType = contentType;
  this.Response.Write(fileText);
  this.Response.End();
}
Typical content types: Text "text/plain" PDF "application/pdf" Got it from: http://coercedcode.blogspot.com/2007/08/sending-files-and-file-contents-to.html. Starting the download with a button inside an UpdatePanel? Register the button for a regular, not partial postback:
ScriptManager.GetCurrent(this.Page).RegisterPostBackControl(exportButton);

Tuesday, January 27, 2009

Page transfer effect that works in Internet Explorer (blendTrans effect)

I can never remember this.
<meta http-equiv="Page-Enter" content="blendTrans(Duration=0.0)">

Monday, January 19, 2009

Quickly check web page performance

Paste this somewhere in your codebehind, putting the dt definitions around the suspected code:
DateTime dt = DateTime.Now;
DateTime dt2 = DateTime.Now; 
DateTime dt3 = DateTime.Now; 
this.debugLiteral.Text = string.Format("<div>|{0}||{1}||{2}|</div>", dt, dt2, dt3);
And paste this somewhere in your aspx:
<asp:Literal ID="debugLiteral" runat="server" />