如何在ASP.NET中设置文章的二级标题或者三级标题
在程序中用代码实现如何保存 如何获取 如何排序
记住是二级标题或者三级标题……
不是单纯的this.title.text = "";
答案://字符串截取类,用于截取标题
//放一个新类 调用直接用函数
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
/// <summary>
/// Strings 的摘要说明
/// </summary>
public class Strings
{
public Strings()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public static string CutString(string inputString, int len)
{
ASCIIEncoding ascii = new ASCIIEncoding();
int tempLen = 0;
string tempString = "";
byte[] s = ascii.GetBytes(inputString);
for (int i = 0; i < s.Length; i++)
{
if ((int)s[i] == 63)
{
tempLen += 2;
}
else
{
tempLen += 1;
}
try
{
tempString += inputString.Substring(i, 1);
}
catch
{
break;
}
if (tempLen > len)
break;
}
//如果截过则加上半个省略号
byte[] mybyte = System.Text.Encoding.Default.GetBytes(inputString);
if (mybyte.Length > len)
tempString += "…";
return tempString;
}
}这上一个页面跳转的时候 用session保存本页面的值.
次页面接受就可以了