Tuesday, July 28, 2009

Create New HTML Page At Run Time

public void CreatePageHTMLRunTime()
{
try
{


WebRequest mywebReq;
WebResponse mywebResp;
StreamReader sr;
string strHTML;
StreamWriter sw;
string currentPageUrl = Request.Url.ToString();
mywebReq = WebRequest.Create(currentPageUrl);
mywebResp = mywebReq.GetResponse();
sr = new StreamReader(mywebResp.GetResponseStream());
strHTML = sr.ReadToEnd();
string replace = "";
string strw="Welcome to Our Website!";

string sView= strHTML.Replace(replace,strw);

sw = File.CreateText(Request.PhysicalApplicationPath + "/Html/" + "Html" + int.Parse(Request.QueryString["OrderId"].ToString()) + ".html");
sw.WriteLine(sView);
sw.Close();
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "message", "self.close();", true);
}
catch
{
}

}
public void Create()
{
string sPath=Request.PhysicalApplicationPath + "/Html/" + "Html" + int.Parse(Request.QueryString["OrderId"].ToString()) + ".html";
FileInfo fi = new FileInfo(sPath);
if (fi.Exists)
{
cmdCreate.Enabled = false;
cmdCreate.Text = "Page already created";
}

}

Thursday, July 9, 2009

Code

Select All Grid Rows-------
--------------------------------------------------------------------------------------------------
function SelectAll(id)
{
//get reference of GridView control
var grid = document.getElementById("<%= grdCompany.ClientID %>");
//variable to contain the cell of the grid
var cell;

if (grid.rows.length > 0)
{

//loop starts from 1. rows[0] points to the header.
for (i=1; i {
//get the reference of first column
cell = grid.rows[i].cells[0];

//loop according to the number of childNodes in the cell
for (j=0; j {
//if childNode type is CheckBox
if (cell.childNodes[j].type =="checkbox")
{
//assign the status of the Select All checkbox to the cell checkbox within the grid
cell.childNodes[j].checked = document.getElementById(id).checked;

}
}
}
}
}

--------------------------------------------------------------------------------------------------