-1

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?

6
  • 2
    save data to a database? Commented May 31, 2016 at 13:00
  • can you please explain your question? Commented May 31, 2016 at 13:01
  • @Ra3IDeN It's the only thing that is going to be edited, i am not gonna use a database just for that thing, if not necessary. Commented May 31, 2016 at 13:09
  • @OmranKaddah try in the cloud. Commented May 31, 2016 at 13:12
  • 1
    If you expected editing the DOM to remain permanent across requests, I suggest you do some research into the stateless nature of the web, so you can understand why that isn't the case. Commented May 31, 2016 at 13:21

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

How to save the content to a file ??
Tale a look at this answer stackoverflow.com/questions/1268766/… 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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.