如何在ASP.NET中将变量从页面传递到另一个页面

nub*_*iee 1 asp.net variables

我想问一下如何将变量从页面传递到另一个页面.

例.

在(page1.aspx.cs)中有按钮单击和文本框

    protected void Button1_Click(object sender, EventArgs e)
    {
        textbox1.text = ;

    }
Run Code Online (Sandbox Code Playgroud)

in(page2.aspx.cs)

A ="hello"// A是可以改变的变量,变量来自microC

我想要的是当我点击page1.aspx中的button1时,从textbox1.text中的page2显示"hello"

Tim*_*mes 5

您可以将值作为查询字符串参数传递.

因此,如果您正在使用,Response.Redirect您可以做类似的事情

protected void Button1_Click(object sender, EventArgs e){
    Response.Redirect("Page2.aspx?value=" + taxtbox1.text);
}
Run Code Online (Sandbox Code Playgroud)

在第2页,您可以使用获取值 Request["value"].ToString()

请注意,查询字符串参数名称是您请求的名称.所以,如果你有?something = else你会要求["某事"]