Requiredfieldvalidator
Requiredfieldvalidator控件,我在用它写表单验证提交后台的时候,一跑起来,美滋滋的抛出了一堆错。。。let’s see~
So the Thrown error(所以抛出错误):
咱直接说解决方案,字多了太无聊
解决方案一
1 | 在aspx页面的Page_Load方法中添加代码: |
解决方案二
1 |
|
解决方案三
1 | 修改Web.config文件如下: |
解决方案四
1 | 修改全局应用程序类Global.asax |
举例使用解决方案一
然后美滋滋跑起来~
有个朋友问到了文字转拼音的方法,我get到了1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54public static string ChineseToFullPinYin(string chinese)
{
// 匹配中文字符
Regex regex = new Regex("^[\u4e00-\u9fa5]$");
byte[] array = new byte[2];
string pyString = "";
int chrAsc = 0;
int i1 = 0;
int i2 = 0;
char[] noWChar = chinese.ToCharArray();
for (int j = 0; j < noWChar.Length; j++)
{
// 中文字符
if (regex.IsMatch(noWChar[j].ToString()))
{
array = System.Text.Encoding.Default.GetBytes(noWChar[j].ToString());
i1 = (short)(array[0]);
i2 = (short)(array[1]);
chrAsc = i1 * 256 + i2 - 65536;
if (chrAsc > 0 && chrAsc < 160)
{
pyString += noWChar[j];
}
else
{
// 修正部分文字
if (chrAsc == -9254)
pyString += "Zhen";
else if (chrAsc == -12080)
{
pyString += "Hang";
}
else
{
for (int i = (pyValue.Length - 1); i >= 0; i--)
{
if (pyValue[i] <= chrAsc)
{
pyString += pyName[i];
break;
}
}
}
}
}
// 非中文字符
else
{
pyString += noWChar[j].ToString();
}
}
return pyString;
}