【问题标题】:Sub String code not working in c#子字符串代码在c#中不起作用
【发布时间】:2015-06-18 05:08:32
【问题描述】:

我写了下面的代码行:

<asp:Label ID="lblDetail" runat="server" Text='<%#_14Communities.Web.CODEFILES.SECUREFILES.WebUtility.LimitString(Server.HtmlDecode((string)Eval("Purpose")).ToString().Replace("\n","<br/>"),200) %>'></asp:Label>

现在我只想显示 200 个字符。它不工作。

【问题讨论】:

  • 请更好地描述问题所在。它是在 ASP 还是 C# 中?实际发生了什么,是否有错误消息或异常?
  • 它可能会帮助你参考这个stackoverflow.com/a/7651192/795683
  • 检查 LimitString 显然它不起作用
  • _14Communities.Web.CODEFILES.SECUREFILES.WebUtility.LimitString 方法有什么作用?你能提供那个方法的代码吗?

标签: c# asp.net


【解决方案1】:

您可以使用简单的内在 dotNet 函数substring

yourString.Substring(0, 200);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-01-04
    • 2018-10-05
    • 2017-09-28
    • 1970-01-01
    • 2020-07-04
    • 1970-01-01
    • 1970-01-01
    • 2021-09-14
    相关资源
    最近更新 更多