Get a value from another page
How can you retrieve a value from one page to another?
For example if you have Webform1 and Webform2 in the Namespace WebApplication1 I would like to do this:
WebForm1.aspx
Code:
.
.
.
public class WebForm1 : System.Web.UI.Page
{
// give public access
public System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
.
.
.
WebForm2.aspx
Code:
.
.
.
public class WebForm2 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
private void Page_Load(object sender, System.EventArgs e)
{
TextBox1.Text = WebForm1.TextBox1.Text;
// Put user code to initialize the page here
}
.
.
.
The error is:
An object reference is required for the nonstatic field, method, or property 'WebApplication1.WebForm1.TextBox1'