您的位置:首页 > 其它

页面间传值的方法?

2007-08-22 21:43 232 查看
今天参加了个面试一共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

private void Button1_Click(object sender, System.EventArgs e)

b.aspx中C#代码

private void Page_Load(object sender, EventArgs e)

<6>Cache

例如:

Cache["prompt"]="Welcome to Olympic's Games"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐