I have an html file in my asp.net webforms project that people can download when clicking a button.
I would like to generate some <select> lists and append to certain parts of the html based on some database values before the file gets sent to the user. Is this possible using c#? My current download functionality:
public void DownloadOfflineAuditSheetEditor(object s, EventArgs e)
{
Response.AppendHeader("content-disposition", "attachment; filename=thefile.html");
Response.WriteFile(Server.MapPath("~/thefile.html"), true);
Response.End();
}
Yes – you’d have to manipulate “the file” before it gets sent to the user.
In your method
DownloadOfflineAuditSheetEditoryou could have call a new method that reads the current file, gets the contents from the DB and then writes to the file or a new file, for example:Then in your original function do:
http://msdn.microsoft.com/en-us/library/ezwyzy7b.aspx – Reading from a file
http://msdn.microsoft.com/en-us/library/aa287548(v=vs.71).aspx – Write to a file