• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 115
  • Last Modified:

asp.net, back button, fields blanked

In asp.net, on a page A, if a user enters a text input value, goes forward, and then later, using back button, goes back to that page A, is there any way to blank out that field, by knowing that they got to it on a back button?
0
codequest
Asked:
codequest
  • 5
  • 3
1 Solution
 
HainKurtSr. System AnalystCommented:
add this to your control (aspx)

EnableViewState="false"
0
 
HainKurtSr. System AnalystCommented:
or on page_load, add this

If Not IsPostBack
  myInput.text=""
End If
0
 
codequestAuthor Commented:
Thanks for responding.  Hmm....Tried both, no joy.

        <asp:TextBox  runat="server"
            ID="f155_PrtcLoginOnlineIDInput"
            cssclass ="f155_PrtcLoginOnlineIDInput"
            enableviewstate ="false"
            />

In page load:
        If Not IsPostBack Then
            Me.f155_PrtcLoginOnlineIDInput.Text = ""
            (and other stuff)

To make sure I've described the scenario properly, I enter text into f155_PrtcLoginOnlineIDInput, and press a button that redirects to another page.

When I hit the back key, the text is still in the f155_PrtcLoginOnlineIDInput field.

I'm trying to make the text be gone when arrive at the page through the back key.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
HainKurtSr. System AnalystCommented:
looks like this is nothing to do with code, but cache issue...

add this to your page

Response.Cache.SetCacheability(HttpCacheability.NoCache)
0
 
HainKurtSr. System AnalystCommented:
or something like this

Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1))
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Cache.SetNoStore()

Open in new window


or this in aspx page

<meta http-equiv=expires content=-1>
<meta http-equiv=Cache-Control CONTENT=no-cache>
<meta http-equiv=Pragma CONTENT=no-cache>

Open in new window

0
 
codequestAuthor Commented:
Thanks, I'll try those.  Where might I put the Response.Cache statements...in Page Load?
0
 
HainKurtSr. System AnalystCommented:
anywhere... page_PreRender is a good place... most of the time it is empty...
0
 
codequestAuthor Commented:
The Response.Cache statements worked in a test program, and I won't be able to put more time into this for a while, so I'm going to accept the answer.    Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now