后台: public string ProductCate = "343";
前台: var s = "<%=ProductCate%>"; //js 得到后台全局变量
调用函数: /// 超过的话用...代替
/// </summary>
/// <param name="str"></param>
/// <param name="length"></param>
/// <returns></returns>
public static string GetString(string str, int length)
{
int i = 0, j = 0;
foreach (char chr in str)
{
if ((int)chr > 127)
{
i += 2;
}
else
{
i++;
}
if (i > length)
{
str = str.Substring(0, j) + "......";
break;
}
j++;
}
return str;
}
前台:<%# GetString(DataBinder.Eval(Container.DataItem, "Vul_ID").ToString(), 30)%>