在 asp.net 标签中显示的文本的约束

发布于 2024-09-27 21:49:24 字数 55 浏览 0 评论 0原文

每个人! 有人可以告诉我如何限制在 asp.net Label 控件中显示的文本行数吗? 谢谢!

everyone!
Could someone tall me how I can limit count of line of text, that is showing in asp.net Label control?
Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

べ映画 2024-10-04 21:49:26

您可以使用此 css 定义单元格(或外部容器)的最大宽度。要定义文本的最大长度,您必须自行将文本截断到最大长度。

.longtext td{ width:100px;word-wrap : break-word ;word-break : normal; }
<asp:Label ID="lblText" runat="server" CssClass="longtext">

lblText.Text=lblText.substring(0,yourMaxLength)

You could use this css to define a max width for the cell(or the outer container). To define a max length of the text, you have to truncate the text to your maximum length by yourself.

.longtext td{ width:100px;word-wrap : break-word ;word-break : normal; }
<asp:Label ID="lblText" runat="server" CssClass="longtext">

lblText.Text=lblText.substring(0,yourMaxLength)
黎夕旧梦 2024-10-04 21:49:26

进行更改.css

.limitWidth {

    white-space: nowrap;     
    max-width: 100px;
    text-overflow: ellipsis;
    overflow-x: hidden;

}

Make changes .css

.limitWidth {

    white-space: nowrap;     
    max-width: 100px;
    text-overflow: ellipsis;
    overflow-x: hidden;

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文