Eval调用函数
前台代码:
<div class="divTable">
<div class="divTableM">
<a href="<%# Eval("Id",FindingUrl(Session["class"].ToString())) %>"
title="<%# Eval("title")%>">
<%# Eval("title").ToString().Length > 15 ? Eval("title").ToString().Substring(0, 14) + "..." : Eval("title").ToString()%>
</a>
</div>
</div>
<div class="divTableM">
<a href="<%# Eval("Id",FindingUrl(Session["class"].ToString())) %>"
title="<%# Eval("title")%>">
<%# Eval("title").ToString().Length > 15 ? Eval("title").ToString().Substring(0, 14) + "..." : Eval("title").ToString()%>
</a>
</div>
</div>
后台代码:
protected string FindingUrl(string sClass)
{
if (sClass == "校园新闻")
{
return "NewsDetail.aspx?Id={0}";
}
else if (sClass == "通知公告")
{
return "InformDetail.aspx?Id={0}";
}
else
{
return "Default.aspx";
}
}
{
if (sClass == "校园新闻")
{
return "NewsDetail.aspx?Id={0}";
}
else if (sClass == "通知公告")
{
return "InformDetail.aspx?Id={0}";
}
else
{
return "Default.aspx";
}
}