Send data from one page to another

前端 未结 5 1261
面向向阳花
面向向阳花 2020-12-01 17:28

I am trying to send form data from one page to another using C# ASP.Net. I have two pages default.aspx and default2.aspx.Here is the code I have in default.aspx:

         


        
5条回答
  •  醉话见心
    2020-12-01 17:56

    Try this in the Page_Load of Default2.aspx.

     if (PreviousPage != null)
            {
                if (((TextBox)PreviousPage.FindControl("TextBox1")) != null)
                {
                    string txtBox1 = ((TextBox)PreviousPage.FindControl("TextBox1")).Text;
                    Response.Write(txtBox1);
                }
            }
    

    And yes you are correct, the data from page 1 will be sent to page 2 if you use the PostBackUrl attribute.

    MSDN link

提交回复
热议问题