【问题标题】:How to Increase Width of Literal control Asp .net如何增加文字控件 Asp .net 的宽度
【发布时间】:2014-08-30 08:19:12
【问题描述】:

我在数据库中存储和检索 pdf 并显示这一点,我使用文字控制

.aspx 代码

 <div >
    <asp:Literal ID="ltEmbed" runat="server" />
</div>

.cs 代码

ltEmbed.Text = string.Format(embed, ResolveUrl("~/FileCS.ashx?Id="), id);

输出

问题陈述

我想像全屏一样增加 Literal 控件的宽度

我试过了

<div style="width:2000px;" >

但无法显示 pdf 全尺寸。

【问题讨论】:

  • 你用什么API来生成pdf?
  • 我不是生成那个 pdf 我只是将它存储到 sql 数据库并从中检索。并使用文字控制显示

标签: c# css asp.net .net


【解决方案1】:

文字将“变成”无论您在其中呈现为文本的什么...我认为它没有特定的大小,除非它本身呈现为 div...

如果它呈现为 div,请尝试将 width = 100% 作为文字控件上的样式。

如果没有,请在 div 上尝试 width = 100%

【讨论】:

  • 感谢您的回答,但它增加了背景大小而不是控制显示 pdf
  • 向我们展示一些呈现的 html?
【解决方案2】:

尝试asp:Content 控制而不是asp:Literal

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
     <object data="URL OF YOUR ASPX PAGE THAT GENERATES THE PDF" type="application/pdf"></object>
</asp:Content>

查看此链接:http://www.nullskull.com/q/10291781/how-to-open-pdf-in-specific-div-tag-on-webform.aspx

【讨论】:

    【解决方案3】:

    我得到了答案我在 .cs 代码中使用了这个

        int id = Convert.ToInt32(Request.QueryString["id"]);
        string embed = "<object data=\"{0}{1}\" type=\"application/pdf\" width=\"100%\" height=\"600px\">";
        embed += "If you are unable to view file, you can download from <a href = \"{0}{1}&download=1\">here</a>";
        embed += " or download <a target = \"_blank\" href = \"http://get.adobe.com/reader/\">Adobe PDF Reader</a> to view the file.";
        embed += "</object>";
        ltEmbed.Text = string.Format(embed, ResolveUrl("~/FileCS.ashx?Id="), id);
    

    【讨论】:

      猜你喜欢
      • 2015-07-30
      • 1970-01-01
      • 1970-01-01
      • 2012-07-19
      • 2023-04-06
      • 1970-01-01
      • 1970-01-01
      • 2020-09-01
      • 1970-01-01
      相关资源
      最近更新 更多