473,385 Members | 1,347 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Go back w/o loading the form?

From a page with a form I collect the fields in the next page. The fields
are compared with a database and if a certain condition does not fit, I want
to go back to the first page with the form, and still keep all the other
fields as they were written.

If I use Response.Redirect the form will be loaded empty again. The same if
I use a button on page 2 with onClick="history.Back". Isn't there a way to
go back and keep the already written fields in the form on the first page,
as if the user just had hit the Back icon in IE?

/ Rolf
Feb 13 '07 #1
4 3171

"Rolf Rosenquist" <ro**@nomail.comwrote in message
news:Ob*************@TK2MSFTNGP02.phx.gbl...
From a page with a form I collect the fields in the next page. The fields
are compared with a database and if a certain condition does not fit, I
want
to go back to the first page with the form, and still keep all the other
fields as they were written.

If I use Response.Redirect the form will be loaded empty again. The same
if
I use a button on page 2 with onClick="history.Back". Isn't there a way to
go back and keep the already written fields in the form on the first page,
as if the user just had hit the Back icon in IE?
There are a number of ways to do this. Here's one that will cope with the
fact that one page posts to another.

ExampleForm.asp

<form method="post" action="Action.asp">
<p>Enter First name: <input type="text" name="FirstName"
value="<%=Session("FirstName")%>"></p>
<p>Enter Second name: <input type="text" name="SecondName"
value="<%=Session("SecondName")%>"></p>
<p><input type="submit" name="submit" value="Click Me"></p>

Action.asp

<%
Dim x, boolValid

For Each x in Request.Form
Session(x) = Request.Form(x)
Next

boolValid = True
'Validate form values
If 'any test fails Then
boolValid=false
End If
If boolValid = false Then Response.Redirect("ExampleForm.asp")
%>

--
Mike Brind
Feb 13 '07 #2
Mike, do you mean that I should then repopulate the form from the Session(x)
if I come back to the first page?
Isn't it too much waste of server memory to use session variables for normal
data between pages?

If someone uses the back button in the browser, all the fields are still
there. Couldn't I do the same thing with asp code?

/ Rolf

"Mike Brind" <pa*******@hotmail.comskrev i meddelandet
news:Oi*************@TK2MSFTNGP05.phx.gbl...
>
"Rolf Rosenquist" <ro**@nomail.comwrote in message
news:Ob*************@TK2MSFTNGP02.phx.gbl...
From a page with a form I collect the fields in the next page. The
fields
are compared with a database and if a certain condition does not fit, I
want
to go back to the first page with the form, and still keep all the other
fields as they were written.

If I use Response.Redirect the form will be loaded empty again. The same
if
I use a button on page 2 with onClick="history.Back". Isn't there a way
to
go back and keep the already written fields in the form on the first
page,
as if the user just had hit the Back icon in IE?

There are a number of ways to do this. Here's one that will cope with the
fact that one page posts to another.

ExampleForm.asp

<form method="post" action="Action.asp">
<p>Enter First name: <input type="text" name="FirstName"
value="<%=Session("FirstName")%>"></p>
<p>Enter Second name: <input type="text" name="SecondName"
value="<%=Session("SecondName")%>"></p>
<p><input type="submit" name="submit" value="Click Me"></p>

Action.asp

<%
Dim x, boolValid

For Each x in Request.Form
Session(x) = Request.Form(x)
Next

boolValid = True
'Validate form values
If 'any test fails Then
boolValid=false
End If
If boolValid = false Then Response.Redirect("ExampleForm.asp")
%>

--
Mike Brind


Feb 13 '07 #3
You can't rely on the back button maintaining form state. The back button
belongs to the browser, and as such is outside of the control of an asp
developer.

Personally, I get pages to post to themselves in the vast majority of cases.
I usually do this kind of thing:

<%
Sub ShowForm
%>
<form method="post" action="">
<p>Enter First name: <input type="text" name="FirstName"
value="<%=Request.form("FirstName")%>"></p>
<p>Enter Second name: <input type="text" name="SecondName"
value="<%=Request.Fom("SecondName")%>"></p>
<p><input type="submit" name="submit" value="Click Me"></p>
<%
End Sub

If Not IsEmpty(Request.Form("submit")) Then
'Form posted
'validate values
'if validation fails, show form
Call ShowForm
Else
Success
Else
Call ShowForm
End If
%>

But of course, some forms need more than one page. If you think that using
session variables will be too much for your environment, you can use a
database, text files, hidden fields etc.

--
Mike Brind

--
Mike Brind



"Rolf Rosenquist" <ro**@nomail.comwrote in message
news:u6****************@TK2MSFTNGP04.phx.gbl...
Mike, do you mean that I should then repopulate the form from the
Session(x)
if I come back to the first page?
Isn't it too much waste of server memory to use session variables for
normal
data between pages?

If someone uses the back button in the browser, all the fields are still
there. Couldn't I do the same thing with asp code?

/ Rolf

"Mike Brind" <pa*******@hotmail.comskrev i meddelandet
news:Oi*************@TK2MSFTNGP05.phx.gbl...
>>
"Rolf Rosenquist" <ro**@nomail.comwrote in message
news:Ob*************@TK2MSFTNGP02.phx.gbl...
From a page with a form I collect the fields in the next page. The
fields
are compared with a database and if a certain condition does not fit, I
want
to go back to the first page with the form, and still keep all the
other
fields as they were written.

If I use Response.Redirect the form will be loaded empty again. The
same
if
I use a button on page 2 with onClick="history.Back". Isn't there a way
to
go back and keep the already written fields in the form on the first
page,
as if the user just had hit the Back icon in IE?

There are a number of ways to do this. Here's one that will cope with
the
fact that one page posts to another.

ExampleForm.asp

<form method="post" action="Action.asp">
<p>Enter First name: <input type="text" name="FirstName"
value="<%=Session("FirstName")%>"></p>
<p>Enter Second name: <input type="text" name="SecondName"
value="<%=Session("SecondName")%>"></p>
<p><input type="submit" name="submit" value="Click Me"></p>

Action.asp

<%
Dim x, boolValid

For Each x in Request.Form
Session(x) = Request.Form(x)
Next

boolValid = True
'Validate form values
If 'any test fails Then
boolValid=false
End If
If boolValid = false Then Response.Redirect("ExampleForm.asp")
%>

--
Mike Brind



Feb 14 '07 #4
Yes it works now with hidden fields, but I have found it is necessary to use
a submit button to get them back to page1. They do not appear, when I try to
do it in the background with Response.Redirect "page1,asp"

Is there a way to catch the hidden fields without a button?
/ Rolf


"Mike Brind" <du***@newsgroups.comskrev i meddelandet
news:%2****************@TK2MSFTNGP06.phx.gbl...
You can't rely on the back button maintaining form state. The back button
belongs to the browser, and as such is outside of the control of an asp
developer.

Personally, I get pages to post to themselves in the vast majority of
cases.
I usually do this kind of thing:

<%
Sub ShowForm
%>
<form method="post" action="">
<p>Enter First name: <input type="text" name="FirstName"
value="<%=Request.form("FirstName")%>"></p>
<p>Enter Second name: <input type="text" name="SecondName"
value="<%=Request.Fom("SecondName")%>"></p>
<p><input type="submit" name="submit" value="Click Me"></p>
<%
End Sub

If Not IsEmpty(Request.Form("submit")) Then
'Form posted
'validate values
'if validation fails, show form
Call ShowForm
Else
Success
Else
Call ShowForm
End If
%>

But of course, some forms need more than one page. If you think that
using
session variables will be too much for your environment, you can use a
database, text files, hidden fields etc.

--
Mike Brind

--
Mike Brind



"Rolf Rosenquist" <ro**@nomail.comwrote in message
news:u6****************@TK2MSFTNGP04.phx.gbl...
Mike, do you mean that I should then repopulate the form from the
Session(x)
if I come back to the first page?
Isn't it too much waste of server memory to use session variables for
normal
data between pages?

If someone uses the back button in the browser, all the fields are still
there. Couldn't I do the same thing with asp code?

/ Rolf

"Mike Brind" <pa*******@hotmail.comskrev i meddelandet
news:Oi*************@TK2MSFTNGP05.phx.gbl...
>
"Rolf Rosenquist" <ro**@nomail.comwrote in message
news:Ob*************@TK2MSFTNGP02.phx.gbl...
From a page with a form I collect the fields in the next page. The
fields
are compared with a database and if a certain condition does not fit,
I
want
to go back to the first page with the form, and still keep all the
other
fields as they were written.

If I use Response.Redirect the form will be loaded empty again. The
same
if
I use a button on page 2 with onClick="history.Back". Isn't there a
way
to
go back and keep the already written fields in the form on the first
page,
as if the user just had hit the Back icon in IE?


There are a number of ways to do this. Here's one that will cope with
the
fact that one page posts to another.

ExampleForm.asp

<form method="post" action="Action.asp">
<p>Enter First name: <input type="text" name="FirstName"
value="<%=Session("FirstName")%>"></p>
<p>Enter Second name: <input type="text" name="SecondName"
value="<%=Session("SecondName")%>"></p>
<p><input type="submit" name="submit" value="Click Me"></p>

Action.asp

<%
Dim x, boolValid

For Each x in Request.Form
Session(x) = Request.Form(x)
Next

boolValid = True
'Validate form values
If 'any test fails Then
boolValid=false
End If
If boolValid = false Then Response.Redirect("ExampleForm.asp")
%>

--
Mike Brind



Feb 14 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Curious George | last post by:
I have a page that takes about 10 seconds to load the first time it is run. I would like to first display a little animated gif telling the user that the page is loading. How do I do this with...
18
by: Alpha | last post by:
Hi, I'm working on a Windows applicaton with VS 2003 on windows 2000. I have a listbox that I have binded to a dataset table, "source" which has 3 columns. I would like to display 2 of those...
8
by: Galina | last post by:
Hello I have 6 dependent list boxes on my ASP page:  Faculty;  Lecturer;  Course;  Course occurrence;  Group;  Week commencing date. When faculty is selected, lists of lecturers and...
0
by: Ivan K | last post by:
Hi, This is probably more of an Internet Explorer-related problem but I thought I would crosspost to microsoft.public.dotnet.framework.aspnet as this problem has probably occured for other...
2
by: Rob | last post by:
I was working on a project and everything was going fine, then all of a sudden the form set as my startup object stopped loading. I tried setting some others as the startup object, and some of my...
3
by: Holmes | last post by:
Hello Ran into a bit of a problem here and have now exhausted my resources to getting this working What I am trying to do is load and show a simple vb form with a listbox in it Dim...
5
by: Cerebrus | last post by:
Hi all, I have an Windows application in which the startup form is called "MainForm". Now when this form loads, I need to do some intensive tasks like loading and parsing an XML file, that takes...
23
by: Bjorn | last post by:
Hi. Every time i post data in a form the contents are being checked for validity. When i click the back-button, all data is gone and i have to retype it. It's obvious that only a few or none of...
8
by: Harvey Schmidlapp | last post by:
I have a fairly complex form (generated by means of an ASP 3 page). The form is used to define a query against a database. After running a query, the user hits their browser's back button and goes...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.