I'm new to ASP.NET and now I am creating an HTML file in ASP.NET C# which is stored in an folder. Now when the aspx file is run it will fetch some data and display it in the output. And there is an button. When I click it the HTML file is created.
Now my problem is I want to fetch the same data in the HTML file also to display it and to save it.
I'm creating the HTML file using StreamWriter and writeline in the code-behind. Or is there any other way to convert that aspx output file into an HTML file and save it in the same folder of the project?
protected void Button1_Click(object sender, EventArgs e)
{
string thisdir = Server.MapPath("./New Folder/SalesContract.htm");
StreamWriter sw = new StreamWriter(thisdir, true);
sw.WriteLine("<html>");
sw.WriteLine("<head>");
sw.WriteLine("<title> Sales Invoice</title>");
.............
sw.WriteLine("<b> <label for=lb_seller1 value=" + ds.Tables[0].Rows[0]["po_seller_Name"].ToString() + "/></b><br/>");
........
sw.WriteLine("</body>");
sw.WriteLine("</html>");
sw.Flush();
sw.Close()
}
It is the sample I'm using. I'm fetching the data to display in the aspx output and it works. Now I also need to fetch the same data in this file also.