如何传递的值从一种形式到另Asp.net形式、Asp、net

由网友(偶尔被需要,从来不重要)分享简介:我如何传递值从一种形式到另一个Asp.net?您可以请给我一个例子吗?我知道了。感谢大家的回答。在源我有写保护无效btnAdd_Click(对象发件人,EventArgs的){会话[名称] = textBox.Text;Server.Transfer的(WebForm1.aspx);}和目标我必须写无效的Page_...

我如何传递值从一种形式到另一个Asp.net?

您可以请给我一个例子吗?

我知道了。感谢大家的回答。

在源我有写

 保护无效btnAdd_Click(对象发件人,EventArgs的)
{
    会话[名称] = textBox.Text;
    Server.Transfer的(WebForm1.aspx);
}
 
asp.net开发中 不同页面之间的传值

和目标我必须写

 无效的Page_Load(对象发件人,EventArgs的)
{
    。answer.Text =会话[名称]的ToString();
    Session.Remove(姓名);
}
 

解决方案

客户端技术: 1)查询字符串 2)饼干

查询字符串: 发送:

字符串名称=ABC;的Response.Redirect(?Page2.aspx名=+姓名);

有关获取: 在Page2.aspx 字符串名称= Response.QueryString.GetValue(姓名);

有关cookies,您可以使用 发送:  的HttpCookie H =新的HttpCookie(); h.Name =名; h.Value =ABC; Response.Cookies.Add(H);

获取: 字符串名称= Request.Cookies时('名');

服务器端技术: 1)会话

有关设置: 会话[名称] =ABC;

有关获取: 字符串str =会话[名称]的ToString();

在会话可以传递任何对象类型。

How can I pass values from one form to another in Asp.net?

Can you please give me an example?

I got it. Thanks for everyone for replying.

In source i have to write

protected void btnAdd_Click(object sender, EventArgs e)
{
    Session["name"] = textBox.Text;
    Server.Transfer("WebForm1.aspx");
}

and in target i have to write

void Page_Load(object sender, EventArgs e)
{
    answer.Text = Session["name"].ToString();
    Session.Remove("name");
}

解决方案

Client side technology: 1)Query String 2)Cookies

Query String: For SEnding:

string name="abc"; Response.Redirect(" Page2.aspx?name= "+name);

For Getting: On Page2.aspx string name=Response.QueryString.GetValue(" name ");

For cookies you can use Sending: HttpCookie h=new HttpCookie(); h.Name="name"; h.Value="abc"; Response.Cookies.Add(h) ;

Getting: string name = Request.Cookies('name');

Server Side Technology: 1)Session

For Setting: Session["Name"] = "Abc";

For Getting: string str = Session["Name"].ToString();

In Session you can pass any object type.

阅读全文

相关推荐

最新文章