ASP.NET跨页面传值技巧总结
1.使用QueryString变量
QueryString是一种非常简单的传值方式,他可以将传送的值显示在浏览器的地址栏中。如果是传递一个或多个安全性要求不高或是结构简单的数值时,可以使用这个方法。但是对于传递数组或对象的话,就不能用这个方法了。下面是一个例子:
a.aspx.cs的C#代码
view plaincopy to clipboardprint?
private void Button1_Click(object sender, System.EventArgs e)
{
string s_url;
s_url = "b.aspx?name=" + Label1.Text;
Response.Redirect(s_url);
}
private void Button1_Click(object sender, System.EventArgs e)
{
string s_url;
s_url = "b.aspx?name=" + Label1.Text;
Response.Redirect(s_url);
}
b.aspx.cs中C#代码
view plaincopy to clipboardprint?
private void Page_Load(object sender, EventArgs e)
{
Label2.Text = Request.QueryString["name"];
}
private void Page_Load(object sender, EventArgs e)
{
Label2.Text = Request.QueryString["name"];
}
2.使用Application 对象变量
Application对象的作用范围是整个全局,也就是说对所有用户都有效。其常用的方法用Lock和UnLock。
a.aspx.cs的C#代码
view plaincopy to clipboardprint?
private void Button1_Click(object sender, System.EventArgs e)
{
Application["name"] = Label1.Text;
相关文档:
发布中遇到了两个问题
一。session 会短时间自动消失
解决办法
1。在www.google.com中查session 丢失
2。在Window服务中将ASP.NET State Service 启动。
3。修改web.config
<system.web>
add <sessionState mode="StateServer" timeout="60"/>
二。sql server 超过最大连接池数
......
在ASP.NET页面中经常需要链入一些JS文件,如:
如果在JS里有中文的话,在一般情况下,在浏览器里会报错脚本错误.
如果不信可以自己试一试。
其实是这样的:
由VS.NET自动生成的项目里,Web.Config中有这么一段:
<
globalization
requestEncoding
="utf-8"
responseEncoding
=" ......
自从IE6 SP1起 , 这个浏览器就支持cookie的httpOnly属性.
这个属性, 告诉浏览器, 使用 window.document.cookie 不允许访问该cookie .
而在ASP.NET2.0中 , 这个属性也得到了支持, 并且在FormAuthentication中指定该属性.
但是,FireFox等浏览器, 并不支持该属性. 那么这个带来什么后果?
例如 , 假如你用FireFox登录博客 ......
开源网页编辑软件FCKEditor在09年发布更新到3.0,并改名为CKEditor。改进后的ckeditor更加模块话,配置更加灵活,和以前的fckeditor使用方式上也有所不同。在我的mvc项目中由于要用到 ckeditor,特意研究了下它的使用方法,写下来和大家分享。
我用的是最新版本的:ckeditor_3.0.1 下载地址:http://ckeditor.com/
......
ASP.NET添加、修改、删除web.config配置信息
1 using System;
2 using System.Data;
3 using System.Configuration;
4 using System.Collections;
5 using Sys ......