zoukankan      html  css  js  c++  java
  • repeater 字段过长

    可以直接substring
    也可以<%# Utility.Common.GetShow( Eval("NewTitle").ToString(),20,true) %>
      <td><%#fcwms.Common.GetContent.GetShow(Eval("com_address").ToString(), 19, true)%> </td> /// <summary > /// 按字节数截取字符串,中文算两个字节,全角字符算两个字节,大写字母也算两个字节 /// </summary > /// <param name="strSrc">要处理的字符串</param> /// <param name="count">要保留的字节数</param> /// <param name="withPoint">设置截取后加不加省略号( "... ")默认的传true</param> /// <returns></returns> public static string GetStrByByteCount(string strSrc, int count, bool withPoint) { Regex regex = new Regex("[\u4e00-\u9fa5]+", RegexOptions.Compiled); char[] stringChar = strSrc.ToCharArray(); StringBuilder sb = new StringBuilder(); int nLength = 0; bool isCut = false; for (int i = 0; i < stringChar.Length; i++) { if ((regex.IsMatch((stringChar[i]).ToString())) || (stringChar[i] > 65280 && stringChar[i] < 65375) || (stringChar[i] > 64 && stringChar[i] < 91)) { nLength += 2; if (nLength > count) { isCut = true; break; } sb.Append(stringChar[i]); } else { nLength = nLength + 1; if (nLength > count) { isCut = true; break; } sb.Append(stringChar[i]); } } if (isCut) { if (withPoint) { return sb.ToString() + "..."; } else { return sb.ToString(); } } else { return sb.ToString(); } }

     方法1:

     <td><asp:Label ID="Label14" runat="server" Text='<%# fcwms.Common.GetContent.GetShow(Eval("com_address").ToString(),19,true)%>'  ToolTip='<%# Eval("com_address")%>'></asp:Label></td>

     方法2:

    <td><asp:Label ID="lblMatNM" runat="server" Text='<%#Eval("matNM").ToString().Length >10?Eval ("matNM").ToString().Substring (0,10)+"...":Eval ("matNM").ToString ()%>' ToolTip ='<%#Eval("matNM")%>'></asp:Label></td>

     无提示:

    <td><%#fcwms.Common.GetContent.GetShow(Eval("com_address").ToString(),19,true)%></td>
  • 相关阅读:
    留言板
    文件操作1
    JQUERY与JS的区别
    PHP 练习租房
    PHP 投票练习
    PHP,单项查询及多项查询
    PHP 增删改查 import!!
    PHP 数据访问
    PHP 对象及其三大特性
    正则表达式和数组
  • 原文地址:https://www.cnblogs.com/LifeKingcn/p/2804350.html
Copyright © 2011-2022 走看看