I currently have an aspx page returning a html form (with images and css). I would like get a download Word editable version of this form without rewrite all the code. Is it possible ?
An example : I Have a page 'WebForm2.aspx' with a simple content like this.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs"
Inherits="WebApplication15.WebForm2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Title</h1>
<asp:CheckBox runat="server" ID="myTest" Text="Doc 1" /><br />
<asp:CheckBox runat="server" ID="myTest2" Text="Doc 2" /><br />
<asp:CheckBox runat="server" ID="myTest3" Text="Doc 3" /><br />
<asp:CheckBox runat="server" ID="myTest4" Text="Doc 4" /><br />
</div>
</form>
</body>
</html>
I would like that from an other page for example a button that lets you download the contents of 'WebForm2.aspx' in an editable Word document.
I Add this in Page_PreRender method
Response.AddHeader("Content-Type", "application/msword");
It's partially work. If I save the document css and images aren't loaded but if I only open the downloadable content css and images are loaded.
MS Word can edit html document so by adding Content-Type=application/msword record in header will make browser open your page in browser unfortunately without css and images.
Add following code in prerender event on your page
Response.AddHeader("Content-Type", "application/msword");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.