求教一个ASP的小问题~高手来 给分!!!

来源:百度知道 编辑:UC知道 时间:2024/05/22 16:01:45
<a href="XXX.asp?id=<%=rs("id")%>"> <%=left(rs("title"),12)%>...</a>
上面这句话,本意是:如果显示字数超过12字,显示信息后面就出现“…” 没超过12字就不出现“…” 但我只会像上面那么写 无论超不超出12字都会出现“…” 哪位高手教我一下

前面加判断:
title=rs("title")
if len(title)>12 then
title=left(title,12)&"..."
end if

<a href="XXX.asp?id=<%=rs("id")%>"> <%=title%></a>

<itemtemplate>
<%#geturl(DataBinder.eval(container.dataitem,"Topic"))%>
</itemtemplate>

在后台新建一函数:
public string geturl(object str)
{
String urlstr=(String)str;
if(urlstr.length>12)
{ urlstr=usrlstr.substring(0,12)+"...";

}
return "<a href='???' tilte='"+(String)str+"'>"+urlstr+"</a>";
}