小编bak*_*ked的帖子

在生成的HTML .doc中插入分页符

我目前正在使用asp.NET 生成一个.doc文件作为html.

我希望在页面中插入分页符,但不知道如何.

我已经尝试过使用css style ='page-break-before:always'但它什么也没做.

这是分配给按钮单击事件的代码:

    HttpContext.Current.Response.Clear();
    HttpContext.Current.Response.Charset ="";

    HttpContext.Current.Response.ContentType ="application/msword";

    string strFileName = "GenerateDocument"+ ".doc";
    HttpContext.Current.Response.AddHeader("Content-Disposition","inline;filename=" + strFileName);

    StringBuilder strHTMLContent = new StringBuilder();

    strHTMLContent.Append("<p align='Center'>Content Before Page Break</p>".ToString());

    strHTMLContent.Append("<br><br>".ToString());
    strHTMLContent.Append("<p class='pageBreak' style='mso-special-character:line-break;'>meh</p>".ToString());

    strHTMLContent.Append("<br><br>".ToString()); 
    strHTMLContent.Append("<p align='Center'>Content After Page Break</p>".ToString());

    HttpContext.Current.Response.Write(strHTMLContent);
    HttpContext.Current.Response.End();
    HttpContext.Current.Response.Flush();
Run Code Online (Sandbox Code Playgroud)

html asp.net ms-word

7
推荐指数
2
解决办法
1万
查看次数

在交叉发布中,PreviousPage = null

我正在尝试将帖子数据从一个页面传递到下一个页面,但PreviousPage总是等于null.

这就是我在原始页面中的内容(在updatepanel内)

<asp:Button ID="mmGo" runat="server" Text="Merge" PostBackUrl="~/Default2.aspx?action=merge"/>
Run Code Online (Sandbox Code Playgroud)

然后在下一页我有:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<%@ PreviousPageType VirtualPath="~/Default.aspx" %>

<!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>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </div>
    </form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

...并在.cs文件中:

protected void Page_Load(object sender, EventArgs e)
{
    if (PreviousPage != null)
    {
        string action = Request.QueryString["action"];
        if (action == "merge")
        {
            UpdatePanel SourceControl = (UpdatePanel)PreviousPage.FindControl("UpdatePanel1");
            HiddenField SourceTextBox = (HiddenField)SourceControl.FindControl("txtListIDs");
            if (SourceTextBox != null) …
Run Code Online (Sandbox Code Playgroud)

asp.net

3
推荐指数
1
解决办法
9981
查看次数

标签 统计

asp.net ×2

html ×1

ms-word ×1