Hide message before redirect to another .aspx page.

G

Guest

Greetings all -

I have been working on this issue for a while now and it has been frustrating to the point where I'm reaching out to the gurus of .NET for any suggestions.

I have a webform where when a user selects an item from a dropdown box and attempts to run a report, if a date is not found in my database, it should return a message to the browser notifying a user that they must select another item to run the report against.

The problem comes in when I do find a valid item to run the report, my code redirects to another page to display the Crystal Report but when I hit the "Back" button, the old error message still displays.

I've tried clearing out the text in the label, setting the label's visibility to false as well as incorporating a custom validator control.............but when I try the custom validator, it does hide itself but then once the redirect to the .aspx file takes place, hitting the "Back" button shows the message still.

Any ideas to how I can set the error message to go away?

Much thanks and cheers,
J.B.
 
M

Michael

You're right, it does save the error message, that's an intended feature of
how web browsers work! They cache! They don't care what technology created
that page they are displaying, they just care that when you move around with
back/forward to display all they knew, unless told otherwise (by the user of
course).

I don't think there is going to be much you can do to stop that, if I
understand your problem correctly. My only suggestion is move the error off
the page you have it on now, to either the report page (and do the error
checking there), or completely different page, so they can click back and
get to the last "state" before they tried to get the report. Oh I'd provide
a link from your report page back to the select-a-report page too, if they
click that, you don't have to worry about that problem.

Don't sweat it too much, my websites do the same thing, I just provide
navigation around my site instead of relying on back buttons, so when a user
gets mad because they see an old error, I'll say it's their own dumb fault
for not clicking the button that I made for them.

J.B. said:
Greetings all -

I have been working on this issue for a while now and it has been
frustrating to the point where I'm reaching out to the gurus of .NET for any
suggestions.
I have a webform where when a user selects an item from a dropdown box and
attempts to run a report, if a date is not found in my database, it should
return a message to the browser notifying a user that they must select
another item to run the report against.
The problem comes in when I do find a valid item to run the report, my
code redirects to another page to display the Crystal Report but when I hit
the "Back" button, the old error message still displays.
I've tried clearing out the text in the label, setting the label's
visibility to false as well as incorporating a custom validator
control.............but when I try the custom validator, it does hide itself
but then once the redirect to the .aspx file takes place, hitting the "Back"
button shows the message still.
 
J

John Timney \(Microsoft MVP\)

You will have to instruct the browser that that page is not cachable by
using the response.addheader properties. I cant recall the exact settings
in asp.net but they will contain this type of stuff (dragged from an old asp
page I have kicking about)

'date in the past...
Response.AddHeader "Expires", "Mon, 26 Jul 1997 05:00:00 GMT"
'always modified
Response.AddHeader "Last-Modified", Now & " GMT"
'HTTP/1.1
Response.AddHeader "Cache-Control", "no-cache, must-revalidate"
'HTTP/1.0
Response.AddHeader "Pragma", "no-cache"
'last ditch attempt!
Response.Expires = -1


--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
----------------------------------------------

J.B. said:
Greetings all -

I have been working on this issue for a while now and it has been
frustrating to the point where I'm reaching out to the gurus of .NET for any
suggestions.
I have a webform where when a user selects an item from a dropdown box and
attempts to run a report, if a date is not found in my database, it should
return a message to the browser notifying a user that they must select
another item to run the report against.
The problem comes in when I do find a valid item to run the report, my
code redirects to another page to display the Crystal Report but when I hit
the "Back" button, the old error message still displays.
I've tried clearing out the text in the label, setting the label's
visibility to false as well as incorporating a custom validator
control.............but when I try the custom validator, it does hide itself
but then once the redirect to the .aspx file takes place, hitting the "Back"
button shows the message still.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top