Hi All,
I have very simple html report generated from one of my objects on server. I generate html code at PageLoad because I need to clear that object from session and don't want ask external web service for data after user clicks on linkbutton.
Roughly idea is that user clicks on button on page and the report will be displayed at new window.
As I said I have html generated at PageLoad and right now stored in unique file at server. I also thought that I could hide the html code in hidden control. But that wont work without extra work, that would convert html code into some nonsense string and restored later on.
I can manage to display my html code into current window by using Response.Write(myhtml as string);
So my question are:
1) where could I store my html code beyond file system (that is tricky with security issues)
2) how to display my htmlcode into new window on click event. What way could I use.
Any comment most welcome..Thanks, X.
I found one possible solution described here.
UPDATE: just adding pieces of code. It displays html string in current window which is not exactly I want.
private void InitData(){
string filename = DateTime.Now.ToString("yyyyMMdd_HHmmssfff");
lbtnPrintOutOrder.CommandArgument = filename;
StreamWriter swXLS = new StreamWriter((MapPath("Files\\")) + filename);
string message = GetEmail();//get data form session object
swXLS.Write(message);//save data to file
swXLS.Close();
}
protected void lbtnPrintOutOrder_Command(object sender, System.Web.UI.WebControls.CommandEventArgs e)
{
string filePath = (MapPath("Files\\")) + e.CommandArgument.ToString();
string content;
using (StreamReader reader = File.OpenText(filePath)) {
content = reader.ReadToEnd();//get html from file
}
Response.Write(content);//load it to current window
Response.End();
}