Search code examples
c#asp.netlinkbuttonbackspace

Keep Data in TextBoxes like on pressing BACKSPACE


I want to keep some informations in some TextBoxes if I go back to this page programmatically. On Page1 I enter the informations and if I click on the button I redirect to the next page, but if an error is in the informations (like text in TextBox for numbers only) I want to go back by clicking on a linkbutton. I tried:

prevPage = Request.UrlReferrer.ToString();
LinkButton1.PostBackUrl = prevPage;

But if get back to the previous page all textboxes are empty. By pressing BACKSPACE on the keyboard, all informations stay kept.

How can I programatically do this to keep the informations like if I am pressing BACKSPACE ???


Solution

  • Just try this javascript on link button click

    history.back()
    

    Example

    <script>
    function goBack()
      {
      window.history.back()
      }
    </script>
    
    <input type="button" value="Back" onclick="goBack()">