Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在Asp.net中将值从一个窗体传递到另一个窗体_C#_.net_Asp.net_Visual Studio - Fatal编程技术网

C# 如何在Asp.net中将值从一个窗体传递到另一个窗体

C# 如何在Asp.net中将值从一个窗体传递到另一个窗体,c#,.net,asp.net,visual-studio,C#,.net,Asp.net,Visual Studio,在Asp.net中,如何将值从一个窗体传递到另一个窗体 你能给我举个例子吗 我明白了。谢谢大家的回复 在源代码中,我必须编写 protected void btnAdd_Click(object sender, EventArgs e) { Session["name"] = textBox.Text; Server.Transfer("WebForm1.aspx"); } void Page_Load(object sender, EventArgs e) { an

在Asp.net中,如何将值从一个窗体传递到另一个窗体

你能给我举个例子吗


我明白了。谢谢大家的回复

在源代码中,我必须编写

protected void btnAdd_Click(object sender, EventArgs e)
{
    Session["name"] = textBox.Text;
    Server.Transfer("WebForm1.aspx");
}
void Page_Load(object sender, EventArgs e)
{
    answer.Text = Session["name"].ToString();
    Session.Remove("name");
}
在target中,我必须写下

protected void btnAdd_Click(object sender, EventArgs e)
{
    Session["name"] = textBox.Text;
    Server.Transfer("WebForm1.aspx");
}
void Page_Load(object sender, EventArgs e)
{
    answer.Text = Session["name"].ToString();
    Session.Remove("name");
}
客户端技术: 1) 查询字符串 2) 饼干

查询字符串: 发送:

string name=“abc”;响应.重定向(“Page2.aspx?name=“+name”)

获取: 在第2.aspx页
string name=Response.QueryString.GetValue(“name”)

对于你可以使用的cookies 发送:
HttpCookie h=新的HttpCookie();
h、 Name=“Name”;
h、 Value=“abc”;
响应.Cookies.添加(h)

获取:
string name=Request.Cookies('name')

服务器端技术: 1) 会议

设置:
Session[“Name”]=“Abc”

获取:
string str=Session[“Name”].ToString()


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

您可以更具体一点吗?我正在开发asp.net应用程序。我有两个名为default.aspx的页面和另一个页面。如果我在Defalut.aspx的文本框中键入内容,它应该显示在第二页。