StringHandler 转换封面图片 截取字符串
View Code
using System; using System.Collections.Generic; using System.Linq; using System.Web; /// <summary> ///StringHandler 的摘要说明 /// </summary> public class StringHandler { /// <summary> /// 转换封面图片路径 /// </summary> /// <param name="isbn">isbn号</param> /// <returns>图片路径</returns> public static String CoverURL(object isbn) { return "BookCovers/" + isbn.ToString().Trim() + ".jpg"; } /// <summary> /// 截取字符串 /// </summary> /// <param name="content">文本</param> /// <param name="num">最大值</param> /// <returns>截取后的字符串</returns> public static String CutString(object content, int num) { if (content.ToString().Length > num) { return content.ToString().Substring(0, num) + "..."; } return content.ToString(); } } ——————————————————————————- <img width="150" height="188" src='<%# StringHandler.CoverURL(Eval("ISBN")) %>' alt="" /> Text='<%# StringHandler.CutString(Eval("AurhorDescription"),120) %>' ToolTip='<%#Eval("AurhorDescription") %>' ></asp:Label> —————————————————————————— <a href='<%#Eval("id") %>'> <%# Eval("New_Content").ToString().Length > 40 ? Eval("New_Content").ToString().Substring(0, 40)+"....." : Eval("New_Content") %></a>
多出隐藏
<div style="width:200px; white-space:nowrap;overflow:hidden;text-overflow:ellipsis; border:1px solid #336699">试试看,前面一段我知道,加上...倒还真的不知道,看看效果</div>