照着网上说的方法,怎么最后就根本没执行前台的js脚本呢
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="exportWord.aspx.cs" Inherits="exportWord" %><!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>Untitled Page</title>
<style type="text/css">
.iframeCss{ width:0; height:0;}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<iframe id="editor" src="about:blank" visible="false" class="iframeCss"></iframe>
<table id="table1">
<tr>
<td>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="111111111111">111111111111</asp:ListItem>
<asp:ListItem>222222</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="Label1" runat="server" Text="Label" Visible="false"></asp:Label>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
<script type="text/javascript" language="javascript">
function CopyTable()
{
CopyHtmlElement(table1)
}function CopyHtmlElement(obj)
{
document.getElementById( "editor").width=0; editor.document.designMode = 'On'; // 将iframe变成可编辑模式,即HTML编辑器
editor.document.write("<body></body>"); // 初始化编辑器
editor.document.body.innerHTML = obj.outerHTML;
editor.document.body.createTextRange().select(); // 选中编辑器内所有内容
editor.document.execCommand("copy","",null); // 复制
}</script>protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = DropDownList1.SelectedValue.ToString();
Label1.Visible = true;
DropDownList1.Visible = false;
ClientScript.RegisterStartupScript(Page.GetType(), "", "CopyTable()true);
string fileName = "测试数据";
ExportWord(fileName);
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="exportWord.aspx.cs" Inherits="exportWord" %><!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>Untitled Page</title>
<style type="text/css">
.iframeCss{ width:0; height:0;}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<iframe id="editor" src="about:blank" visible="false" class="iframeCss"></iframe>
<table id="table1">
<tr>
<td>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="111111111111">111111111111</asp:ListItem>
<asp:ListItem>222222</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="Label1" runat="server" Text="Label" Visible="false"></asp:Label>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
<script type="text/javascript" language="javascript">
function CopyTable()
{
CopyHtmlElement(table1)
}function CopyHtmlElement(obj)
{
document.getElementById( "editor").width=0; editor.document.designMode = 'On'; // 将iframe变成可编辑模式,即HTML编辑器
editor.document.write("<body></body>"); // 初始化编辑器
editor.document.body.innerHTML = obj.outerHTML;
editor.document.body.createTextRange().select(); // 选中编辑器内所有内容
editor.document.execCommand("copy","",null); // 复制
}</script>protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = DropDownList1.SelectedValue.ToString();
Label1.Visible = true;
DropDownList1.Visible = false;
ClientScript.RegisterStartupScript(Page.GetType(), "", "CopyTable()true);
string fileName = "测试数据";
ExportWord(fileName);
ClientScript.RegisterStartupScript(Page.GetType(), "", "CopyTable();", true);