会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
robot.h--为之漫笔
上海优化公司
上海装修公司
博客园
首页
订阅
管理
页面间传值的方法?
今天一道面试题
今天参加了个面试一共9道题
1
:页面间传值的方法
?
<
1
>
通过QueryString[GET]方式
这种方式一般传递安全性不高的简单类型,像Array,Object就不可以传递
Server.Transfer,Server.Execute()
Response.Redirect()
例如:
string
url
=
"
http://www.baidu.com?UserName=
"
+
this
.UserName.Text;
<
2
>
使用Application全局变量
例如:
Application.Lock();
Application[
"
UserName
"
]
=
"
Roboth
"
;
Application.UnLock();
<
3
>
使用Session
例如:
Session.Add(
"
UserName
"
,
"
Roboth
"
);
<
4
>
使用Cookie
HttpCookie cookie
=
new
HttpCookie(
"
UserName
"
);
cookie.Value
=
"
Roboth
"
;
Response.AppendCookie(cookie);
<
5
>
Server.Transfer
例如:
a.aspx的C#代码
public
string
Name
{
get
{
return
Label1.Text;}
}
private
void
Button1_Click(
object
sender, System.EventArgs e)
{
Server.Transfer(
"
b.aspx
"
);
}
b.aspx中C#代码
private
void
Page_Load(
object
sender, EventArgs e)
{
a newWeb;
//
实例a窗体
newWeb
=
(source)Context.Handler;
string
name;
name
=
newWeb.Name;
}
<
6
>
Cache
例如:
Cache[
"
prompt
"
]
=
"
Welcome to Olympic's Games
"
posted @
2007-08-22 21:43
roboth
阅读(
276
) 评论(
0
)
收藏
举报
刷新页面
返回顶部
公告