Ever wanted to get rid of VIEWSTATE, FORM and other INPUT fields in ASP.NET?
Ever wanted to get rid of Top of Form and Bottom of Form labels inside of the generated word document?
Ever wanted to get rid of INPUT fields inside of the generated word document?
The solution is simple and apsolutely FREE! Enjoy!
C# Code:
private void ConvertToWord()
{
// Get Rid of VIEWSTATE and FORM tags
TextWriter textWriter = new StringWriter();
Server.Execute("test.aspx", textWriter);
Response.Output.Write(textWriter.ToString().Replace("form_tag_open", "your_tag_open").Replace("form_tag_close", "your_tag_close").Replace("input_tag_open", "your_tag_open").Replace("input_tag_close", "your_tag_close"));
// Convert to WORD
Response.ContentType = "application/msword";
Response.AddHeader("content-disposition", "attachment; filename=My_WORD_Document.doc");
}
No comments:
Post a Comment