How can I return to a page after doing a Response.Redirect and have the exact page previously?

In my ASP.NET page, I have a textbox and a Submit button and a Required Field Validator on the textbox. I have the EnableClientScript set to False so that the required field is only validated on the server side, which subsequently displays an error message. When I start the Web page and click submit without entering something in the textbox, an error message displays. Next, when I enter a few characters in the box and press the Submit button, the message disappears and the VB code redirects the page to a blank page (Default.aspx). When I press the back button on the browser, the previous Web page appears with the error message appearing and the characters I entered in the box. I am not wanting to see this error message when I return to the Web page. How can that be cleared out upon returning?

If the EnableClientScript is set to True, there are no issues. The error message appears on the client side (no post back), then I enter some text, the message goes away and I am redirected to the blank page, then I press the back button and I arrive on the previous page with my entry in the textbox and no error message.

I have simplified my real-world problem to this simple example, but I am wanting to have server side error messages appear, be fixed, then redirect to another page upon submission, then return to the clean page with the proper entry(s) without erroneous error messages that occurred two pages (postbacks) back.

To describe my real-world scenario one step further, I also have a drop-down list that is validated. When the wrong entry is selected (based on knowledge from a database searched on the server), the server-side displays an error message. When the correct drop-down item is selected and the submit button pressed, the page is redirected to another page. When back button is pressed, the server side error message appears eventhough the screen shows the correct drop-down item is selected (on the page), but viewing the source code of the page shows that the previously incorrect drop-down item is "selected". This is strange to me, but I have a feeling some experts may have some ideas to resolve this issue for me.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="ControlsDemo.aspx.vb" Inherits="ControlsDemo" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Submit Information" />
        <br />
        <asp:RequiredFieldValidator 
            ID="RequiredFieldValidator1" 
            runat="server" 
            ControlToValidate="TextBox1" 
            ErrorMessage="You must enter something" 
            EnableClientScript="False">
        </asp:RequiredFieldValidator>
   
    </div>
    </form>
</body>
</html>



Partial Class ControlsDemo
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Page.IsValid Then
            Response.Redirect("Default.aspx")
        End If
    End Sub
End Class

Open in new window

dwoolley3Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mahone7Commented:
You Can use a javascript

<form>
<input type="button" value="Back to Previous Page"
onClick="javascript: history.go(-1)">
</form>
maybe its help you
0
dwoolley3Author Commented:
Thanks, but the Response.Redirect places the user on another Web site and the user will probably press the Back button on their browser to come back to my Web tool. I want the Web Tool to then display the same information as before but without any of the error messages previously displayed (since the data was fine when the user pressed the Submit button).
0
dwoolley3Author Commented:
This question is still open, after a month of no responses. Does anyone know how to clear error messages that appeared on the screen prior to being redirected to a new page? I want to be able to go back to this prior page (using the back button) and not see those error messages (either from a server-side Validator or from a label set at the server). Does anyone need any further information from me?
0
dwoolley3Author Commented:
The way I was able to resolve my own issue was to write the Validation messages only from the Server (not from the Client) and to surround the validation in AJAX UpdatePanel. Thus, the error message appears for a problem, but after correcting the problem and clicking submit, which redirects to a new location, I can press the back button on the browser and return to the initial page without seeing an error message.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.