0

First I create a page with a textbox and a button; when the button is clicked, it redirects to another page.

This is the code for the redirected page:

protected void Page_Load(object sender, EventArgs e)
{
    if (Page.PreviousPage != null)
    {
        TextBox SourceTextBox =
            (TextBox)Page.PreviousPage.FindControl("TextBox");
        if (SourceTextBox != null)
        {
            form1.InnerHtml = SourceTextBox.Text;
        }
    }
}

Now, I've what is written in the text box is displayed but the changes in the form aren't permanent. When I close the page then I open it again, it doesn't display what I have written before.

Is there any way to make the changes in the form permanent when I use .innerHtml?

Emanuele
  • 648
  • 12
  • 33
Omranovic
  • 45
  • 7

1 Answers1

2

Not without adding some storage solution. All you're doing here is editing the inner HTML of the form in the single instance of the page being rendered on the server, any other users loading the page will not see your changes, and as you have already discovered reloading the page yourself discards the content and reloads from the server.

You could save the content to a file on the server, store it in a database on your server, or perhaps use an online solution like Google's Firebase if you don't have access your your own DB server.

Ben J. Boyle
  • 306
  • 1
  • 12
  • How to save the content to a file ?? – Omranovic May 31 '16 at 13:10
  • 1
    Tale a look at this answer http://stackoverflow.com/questions/1268766/writing-file-to-web-server-asp-net Several things to think about: a) Try not to write to the root of your site, save your data in a separate folder because... b) You'll need to give permissions to the web process to be able to write to the folder, and you don;t want your root folder accessible and writable. – Ben J. Boyle May 31 '16 at 13:17