asp.net准确截取文本长度(取得标题的字符数)
asp.net中自带的CutString只能截取字符数量的长度,但中英文字符数有差异,一个中文字等同于二个英文字符的宽度,这样对截取后的效果不理想.使用以下的方法就能解决.
//调用方法
string title=BLL.CutStr.CutString("标题",10);using System;
using System.Collections.Generic;
using System.Text;
namespace BLL
{
public class CutStr
{
public static string CutString(string str, int length)
{
if (str == "" )
{
str = "没有信息";
}
else
{
int i = 0, j = 0;
foreach (char chr in str)
{
if ((int)chr > 127)
{
i += 2;
}
else
&nbs
相关文档:
Ajax现在已经是相当流行的技术了,Ajax不仅是想服务器端发送消息,更重要的是无刷新的重载页面。
如果页面单纯的使用js来创建,要写大量的代码,而且不直观。
在asp.net中,其实我们可以创建用户自定义控件,通过Ajax请求返回用户自定义控件HTML代码。
public static string RangerUsControl(string controlName) ......
一).创建部署项目
1. 在“文件”菜单上指向“添加项目”,然后选择“新建项目”。
2. 在“添加新项目”对话框中,选择“项目类型”窗格中的“安装和部署项目”,然后选择“模板”窗格 ......
1.设置web.config文件.
<system.web>
......
<globalization requestEncoding="gb2312" responseEncoding="gb2312" culture="zh-CN" fileEncoding="gb2312" />
......
</system.web>
或者:
aspx文件中:
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"&g ......
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;namespace md5
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(UserMd5("8"));
Console.WriteLine(GetMd5Str("8"));
}
/**//// <summary>
/// MD5 16位加密
......