469,571 Members | 1,419 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,571 developers. It's quick & easy.

Hide message before redirect to another .aspx page.

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.
Nov 18 '05 #1
2 2911
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." <an*******@discussions.microsoft.com> wrote in message
news:28**********************************@microsof t.com...
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.

Nov 18 '05 #2
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." <an*******@discussions.microsoft.com> wrote in message
news:28**********************************@microsof t.com...
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.

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Jurjen de Groot | last post: by
2 posts views Thread by Microsoft News | last post: by
2 posts views Thread by bhavik | last post: by
3 posts views Thread by Arjen | last post: by
5 posts views Thread by =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.