62,046
社区成员
发帖
与我相关
我的任务
分享
/// 截取字符串并限制字符串长度,多于给定的长度+。。。
///
/// 待截取的字符串
/// 每行的长度,多于这个长度自动换行
/// 输出字符串最大的长度
///
public string CutStr(string str,int len,int max)
{
string s="";
string sheng="";
if (str.Length >max)
{
str=str.Substring(0,max) ;
sheng="";
}
for(int i=0;i 53 {
int r= i% len;
int last =(str.Length/len)*len;
if (i!=0 && i<=last)
{
if( r==0)
{
s+=str.Substring(i-len,len)+"
";
}
}
else if (i>last)
{
s+=str.Substring(i-1) ;
break;
}
}
return s+sheng;
}
<asp:Repeater ID="RepeaterArticlelist" runat="server">
<ItemTemplate>
<table border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td height="30" class="title01" align="left">
<%=标题%> </td>
</tr>
<tr>
<td height="88" class="text">
<%=内容%><br />
</td>
</tr>
<tr>
<td height="20" class="title02">
<a href="target="_blank">>> 阅读全文...</a>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>