473,791 Members | 3,015 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Redire ct the form will be loaded empty again. The same if
I use a button on page 2 with onClick="histor y.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 3195

"Rolf Rosenquist" <ro**@nomail.co mwrote in message
news:Ob******** *****@TK2MSFTNG P02.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.Redire ct the form will be loaded empty again. The same
if
I use a button on page 2 with onClick="histor y.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="<%=Sessi on("FirstName") %>"></p>
<p>Enter Second name: <input type="text" name="SecondNam e"
value="<%=Sessi on("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.Redire ct("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*******@hotm ail.comskrev i meddelandet
news:Oi******** *****@TK2MSFTNG P05.phx.gbl...
>
"Rolf Rosenquist" <ro**@nomail.co mwrote in message
news:Ob******** *****@TK2MSFTNG P02.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.Redire ct the form will be loaded empty again. The same
if
I use a button on page 2 with onClick="histor y.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="<%=Sessi on("FirstName") %>"></p>
<p>Enter Second name: <input type="text" name="SecondNam e"
value="<%=Sessi on("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.Redire ct("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="<%=Reque st.form("FirstN ame")%>"></p>
<p>Enter Second name: <input type="text" name="SecondNam e"
value="<%=Reque st.Fom("SecondN ame")%>"></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.co mwrote in message
news:u6******** ********@TK2MSF TNGP04.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*******@hotm ail.comskrev i meddelandet
news:Oi******** *****@TK2MSFTNG P05.phx.gbl...
>>
"Rolf Rosenquist" <ro**@nomail.co mwrote in message
news:Ob******* ******@TK2MSFTN GP02.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.Redire ct the form will be loaded empty again. The
same
if
I use a button on page 2 with onClick="histor y.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.as p

<form method="post" action="Action. asp">
<p>Enter First name: <input type="text" name="FirstName "
value="<%=Sess ion("FirstName" )%>"></p>
<p>Enter Second name: <input type="text" name="SecondNam e"
value="<%=Sess ion("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.Redire ct("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.Redire ct "page1,asp"

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


"Mike Brind" <du***@newsgrou ps.comskrev i meddelandet
news:%2******** ********@TK2MSF TNGP06.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="<%=Reque st.form("FirstN ame")%>"></p>
<p>Enter Second name: <input type="text" name="SecondNam e"
value="<%=Reque st.Fom("SecondN ame")%>"></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.co mwrote in message
news:u6******** ********@TK2MSF TNGP04.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*******@hotm ail.comskrev i meddelandet
news:Oi******** *****@TK2MSFTNG P05.phx.gbl...
>
"Rolf Rosenquist" <ro**@nomail.co mwrote in message
news:Ob******** *****@TK2MSFTNG P02.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.Redire ct the form will be loaded empty again. The
same
if
I use a button on page 2 with onClick="histor y.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="<%=Sessi on("FirstName") %>"></p>
<p>Enter Second name: <input type="text" name="SecondNam e"
value="<%=Sessi on("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.Redire ct("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
3124
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 .NET? I used to create a loading layer at the top of the page. Flush the layer to the buffer.
18
3352
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 columns, "scode" and "sname", as 1 column (if not possible then 2 columns will be fine) in the listbox. Can the listbox display 2 columns information from the dataset and how can I do that? Also, I set the property of the listbox to selectionmode...
8
2585
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 courses are populated. When course is selected, lists of occurrences, groups and
0
1199
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 ASP.NET programmers. I have a web form which sends a dynamically generated Excel spreadsheet to the client by intercepting Response.OutputStream. Because I'm intercepting page's OutputStream, the document gets sent to the client at the same URL
2
1978
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 forms will load and others won't. Those that won't load at startup don't load with the Show or ShowDialog command either. Can anyone give me a hint as to what went wrong?
3
2614
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 frm_nc_code As New frm_nc_sen frm_nc_code.Show( Well what I want to have happen is it loads the form then shows all of the controls on the form (especially the listview control which should be blank at this time)
5
1153
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 about 10-12 secs. Initially I was doing it through Multi-threading, by calling the intensive function (refer to as "LongTask()"), in a separate thread, in the Load Event of the form. But the pitfall was that the user could click the MenuItem...
23
14523
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 the visitors will retype it all so i'm asking: "how to preserve POST-data when clicking the back-button?" i've already tried to print post data as a value in a HTML tag but
8
4750
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 back to the form, where their selections show up. They can change whatever they want to change and resubmit the new query. Mostly, everything works fine, with radio buttons, selection lists, check boxes all coming back in the state they were in...
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9515
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10427
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10155
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5431
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4110
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.