3

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 ???

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Pali
  • 1,337
  • 1
  • 14
  • 40

1 Answers1

2

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()">
Pranay Rana
  • 175,020
  • 35
  • 237
  • 263
  • Thanks for your answer, so i have to do this in the .aspx file? Is there any way i can to this in the .cs file with a c# command? This action also belongs to a passed variable from this previous page (if there was an error or not) so could u just show me how i can write this in the .aspx file with a if()? The URL is like error.aspx?=true or "false". In the c# i can handle this but i dont know how to do this in asp. I am a beginner xD – Pali Jan 13 '13 at 15:45
  • @user1879409 - yes you have to try in aspx only...not in code behind file...this is good way to do it – Pranay Rana Jan 13 '13 at 15:46
  • Is there any way i can to this in the .cs file with a c# command? This action also belongs to a passed variable from this previous page (if there was an error or not) so could u just show me how i can write this in the .aspx file with a if()? The URL is like error.aspx?=true or "false". In the c# i can handle this but i dont know how to do this in asp. I am a beginner xD – Pali Jan 13 '13 at 15:49