Solved

asp.net, back button, fields blanked

Posted on 2014-12-21
8
85 Views
Last Modified: 2015-01-06
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
Comment
Question by:codequest
  • 5
  • 3
8 Comments
 
LVL 51

Expert Comment

by:HainKurt
ID: 40512034
add this to your control (aspx)

EnableViewState="false"
0
 
LVL 51

Expert Comment

by:HainKurt
ID: 40512038
or on page_load, add this

If Not IsPostBack
  myInput.text=""
End If
0
 
LVL 2

Author Comment

by:codequest
ID: 40512098
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
 
LVL 51

Expert Comment

by:HainKurt
ID: 40512229
looks like this is nothing to do with code, but cache issue...

add this to your page

Response.Cache.SetCacheability(HttpCacheability.NoCache)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 51

Accepted Solution

by:
HainKurt earned 500 total points
ID: 40512230
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
 
LVL 2

Author Comment

by:codequest
ID: 40512297
Thanks, I'll try those.  Where might I put the Response.Cache statements...in Page Load?
0
 
LVL 51

Expert Comment

by:HainKurt
ID: 40512440
anywhere... page_PreRender is a good place... most of the time it is empty...
0
 
LVL 2

Author Comment

by:codequest
ID: 40517827
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
asp.net bundle 8 47
Binding a check box in an Asp.net DataGrid 4 40
SQL best practice question 3 36
Ajax Panel Not Updating When Triggered By Timer 4 44
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now