Wednesday, May 27, 2009

JavaScript To View Page in Full Screen

Add Following Lines in Script Tag:

url = "FullScreenPage.htm";
var speedX = 7;
var speedY = 5;
var bgColor = "#000000";
var txtColor = "#FF80000";
if (document.all)
{
var wide = window.screen.availWidth;
var high = window.screen.availHeight;
}
function ShowFullScreen()
{
if (document.all)
{
var FScreen = window.open("","BoomWindow","fullscreen");
FScreen.document.write('Loading...');
FScreen.focus();
for (H=1; H{
FScreen.resizeTo(1,H);
}
for (W=1; W{
FScreen.resizeTo(W,H);
}
FScreen.location = url;
}
else
{
window.open(url,"BoomWindow","");
}
}

Call ShowFullScreen() method using javascript event.

Tuesday, May 19, 2009

ASP.NET Export DataGrid To Excel

Its Very easy to Export DataGrid to Excel. First you populate DataGrid and add following code to export datagrid data to excel. Here datagrid object is 'dgBillDetails'.


Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
this.EnableViewState = false;
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
DataGrid1.VirtualItemCount = 0;
DataGrid1.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();