Happy Friday Experts!
I have a website, where there is a submit button which has code as below
If Page.IsValid Then
Dim dsCustInfo As DataSet = New DataSet()
Dim dsDealerInfo As DataSet = New DataSet()
Dim dsAsDealerInfo As DataSet = New DataSet()
Dim dsVehicleInfo As DataSet = New DataSet()
Dim dsOtherDetails As DataSet = New DataSet()
InsertData()
SendEmail()
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "scr", "closeLoading();", True)
ClearAll()
Session.Abandon()
ViewState.Clear()
Page.Response.Cache.SetCacheability(HttpCacheability.NoCache)
' ClientScript.RegisterStartupScript(Me.GetType(), "myalert", "Your information has been submitted successfully", True)
Dim message As String = "alert('Your information has been submitted successfully.')"
ScriptManager.RegisterClientScriptBlock(TryCast(sender, Control), Me.GetType(), "alert", message, True)
Else
Dim ms As String = "alert('Please enter required fields.')"
ScriptManager.RegisterClientScriptBlock(TryCast(sender, Control), Me.GetType(), "alert", ms, True)
End If
And on the client click of same button, I have following javascript code...
function Valid() {
debugger;
var totalRows = $("#<%=gdvLineItems.ClientID %> tr").length;
if (totalRows != 0) {
if (Page_ClientValidate("Required") == true) {
PrintPanel();
blockUI();
return true;
}
else {
validateAndHighlight();
alert("Please fill the Required fields");
return false;
}
}
else {
alert("Please Add Line Items/ Tires");
return false;
}
}
Now, all the validations are working perfectly.
After I submit, I get a message from code behind "Success message" and now I moved to a different page2.aspx. It is loaded without any problem. I decided to click on back button of browser and I see that success message instead of showing me entirely the page. It shows the Alert message (success message) .
Could someone help me with this?
I believe I have something to do with caching and postbacks but not sure how or what to do