易截截图软件、单文件、免安装、纯绿色、仅160KB

asp.net(C#)中文乱码问题

asp.net默认的编码是UTF-8
js文件里的编码也是UTF-8
当你要在aspx页面上进行传中文参数时会出现乱码
<-----request.aspx--接收参数页----->
<----response.aspx--传送参数页----->
例一:<a href="request.aspx?str=中国人"></a>
解决办法一:
1.可以和改webconfig的编码 如:
        <location path='response.aspx'>
            <system.web>
                <globalization fileEncoding='gb2312' requestEncoding='gb2312' responseEncoding='gb2312' culture='zh-CN'/>
            </system.web>
        </location>
注意:你也要把request.aspx页面上的编码也改成同样的,虽然中文乱码解决了,但如果你用到了js文件就会出现乱码
//用这以上方法的话不会改变网站的其它页面上的编码
        <location path='request.aspx'>
            <system.web>
                <globalization fileEncoding='gb2312' requestEncoding='gb2312' responseEncoding='gb2312' culture='zh-CN'/>
            </system.web>
        </location>
解决办法二:
1.如果你不想动webconfig 你可以在”response.aspx.cs“里面对参数进行编码 如:response.aspx在页面上:
<a href="request.aspx?str=<%=str%>"></a>
response.cs页面上:
         声明一个变量str
        public string str="中国人";
        str= HttpUtility.UrlEncode(str,System.Text.Encoding.GetEncoding("GB2312"));
//这时str已经是编码后的
2.而在request.aspx.cs文件中也要进行转换 如:
声明一个变量  
System.Collections.Specialized.NameValueCollection gb2312=HttpUtility.Parse


相关文档:

ASP.NET MVC Uploading and Downloading Files


If you come to ASP.NET MVC from a purely ASP.NET Web Forms background, one of the first things you are likely to notice is that all those nice easy Server Controls have disappeared. One of those is the FileUpload, and its absence seems to cause a few problems. This article looks at how to upload f ......

C# DllImport的用法

大家在实际工作学习C#的时候,可能会问:为什么我们要为一些已经存在的功能(比如Windows中的一些功能,C++中已经编写好的一些方法)要重新编写代码,C#有没有方法可以直接都用这些原本已经存在的功能呢?答案是肯定的,大家可以通过C#中的DllImport直接调用这些功能。
DllImport所在的名字空间 using System.Runtime.Inte ......

C#画线控件的开发应用实例解析

C#画线控件的应用实例介绍之前我们要明白在C#中没有画线的控件,这里写了一个,大家分享。共有两个控件分别是画横线和画竖线的,关于怎么画斜线有兴趣的可以做一个大家分享。
    C#画线控件之横线
using System;  
using System.Collections;  
using System.ComponentModel; ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号