How to move text from one web form text box to ano

2019-09-12 08:56发布

问题:

I'm trying to load text from one text box in my Admin Web Form, to my Home Page web form text box

I have tried this code but I literally can not get it working since my admin class will not detect the control from the other web form..

回答1:

You can use Session variables to transfer text (or data) from one page to another.

In the source page, you save the data in the Session variable:

Session["HomeText"] = txtHomeEntry.Text;

In the destination page, you load the save text:

txtHome.Text = (string)Session["HomeText"];

You can use additional Session variables (e.g. Session["AboutUs"]) to transfer the other data.