<asp:TextBox ID="txtDescription" runat="server" TextMode="MultiLine" Height="100" Width="280"></asp:TextBox> <asp:LinkButton ID="lb_Download" runat="server" Text="Download file" OnClick="lb_Download_Click"></asp:LinkButton>
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { txtDescription.Text = "lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."; } } protected void lb_Download_Click(object sender, EventArgs e) { string strContents = null; strContents = txtDescription.Text; string attachment = "attachment; filename=test.docx"; Response.ClearContent(); Response.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; Response.AddHeader("content-disposition", attachment); Response.Write(strContents); Response.End(); }
Response.ContentType = "application/vnd.ms-word.document";
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)