If one page executes Response.Redirect () on another web page, can the new page access values ​​in asp.net be controlled from the original page?

I have a text string value that I would like to save from one web page to another without using query strings or session / presentation states. I am trying to get ASP http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hiddenfield.aspx "> HiddenField to transfer information from one web form to different .

All examples of hidden field management I saw is to save round trips from client to server for the same form.

Is there a way for the form to access ASP controls (and their values) from a previously created form? Or the original form is simply deleted in memory by then when does the second form execute its OnLoad Method ?

+3
source share
5

- . , Server.Transfer, - . " ", .

http://mysite.com/Page1.aspx, , Server.Transfer( "Page2.aspx" ). Page2.aspx , URL- Page1.aspx, /.

Server.Transfer - , , , , ; Cookie, QueryString, Session, Database - .

+4

Response.Redirect. :

if (Page.PreviousPage != null)
{
    TextBox SourceTextBox = 
        (TextBox)Page.PreviousPage.FindControl("TextBox1");
    if (SourceTextBox != null)
    {
        Label1.Text = SourceTextBox.Text;
    }
}
+3

, Server.Transfer:

firstpage.aspx:

protected void Page_Load(object sender, EventArgs e)
{
    Server.Transfer("~/secondpage.aspx");
}

secondpage.aspx:

protected void Page_Load(object sender, EventArgs e)
{
    Page previousPage = (Page) HttpContext.Current.PreviousHandler;
    Label previousPageControl = (Label) previousPage.FindControl("theLabel");
    label.Text =previousPageControl.Text;
}

, , .

+2

, Response.Redirect() Location: HTTP .

HTTP , , .

.

  • javascript .
  • ( , )
  • -

, , , ( , , , 2

0

, Response.Redirect . , . , , .

, ?

0

Source: https://habr.com/ru/post/1698018/


All Articles