Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

asp.net, back button, fields blanked

Posted on 2014-12-21
8
91 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used.

789 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