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">
<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Submit Information" />
ErrorMessage="You must enter something"
Partial Class ControlsDemo
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If Page.IsValid Then