473,383 Members | 1,877 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,383 software developers and data experts.

form remembers previous text-field values

Hi,

I've got a small problem using 2 asp pages.....

The first page has a button to go to the second page.

On the second page, when the page is loaded, a check is excecuted to see if
a session exists. If so, some values will be used to fill some textfields.
When clicking on the button on the second page, the first page appeirs
again.

But when i change te values of the text-field on the second page and click
on the button again to save the new values back to the session, the values
of the previous time are used and not the new one...

Could someone please help me ...?

Thanx

John


Oct 29 '07 #1
6 1383
"John Devlon" <jo********@hotmail.comwrote in message
news:wz**********************@phobos.telenet-ops.be...
I've got a small problem using 2 asp pages.....
Are these ASP pages or ASP.NET pages...?
On the second page, when the page is loaded, a check is excecuted to see
if a session exists.
A session will always exist - do you mean that a check is executed to see if
a particular sssion variable exists...?
But when i change te values of the text-field on the second page and click
on the button again to save the new values back to the session, the values
of the previous time are used and not the new one...
On the assumption that you're using ASP.NET and not ASP, are you fetching
the values from session every time the second page loads, even if as a
result of a postback...?

Also, AAMOI, is there any particular reason that you're using two pages for
this...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 29 '07 #2
Dear Mark,

Yes, I'm using asp.net... And I'm checking for a partical session
variable...

Every time, the second page is loaded, some information is read from the
session variable...

I just would like to know why the second time the page is visited and a
button is clicked, the values of the first time is used, and not the new
ones ...
How can i prevent this ?

John
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netschreef in bericht
news:ef**************@TK2MSFTNGP05.phx.gbl...
"John Devlon" <jo********@hotmail.comwrote in message
news:wz**********************@phobos.telenet-ops.be...
>I've got a small problem using 2 asp pages.....

Are these ASP pages or ASP.NET pages...?
>On the second page, when the page is loaded, a check is excecuted to see
if a session exists.

A session will always exist - do you mean that a check is executed to see
if a particular sssion variable exists...?
>But when i change te values of the text-field on the second page and
click on the button again to save the new values back to the session, the
values of the previous time are used and not the new one...

On the assumption that you're using ASP.NET and not ASP, are you fetching
the values from session every time the second page loads, even if as a
result of a postback...?

Also, AAMOI, is there any particular reason that you're using two pages
for this...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 29 '07 #3
"John Devlon" <jo********@hotmail.comwrote in message
news:ja**********************@phobos.telenet-ops.be...
Yes, I'm using ASP.NET... And I'm checking for a particalar session
variable...
OK. For future reference, it really helps if you use the correct terms for
things, otherwise people constantly have to ask you what you really mean...
Every time, the second page is loaded, some information is read from the
session variable...

I just would like to know why the second time the page is visited and a
button is clicked, the values of the first time is used, and not the new
ones ...
How can I prevent this ?
It's a little difficult to say for sure as you haven't shown any of your
code, but I'm suspecting that you've forgotten to wrap your Page_Load code
in an if (!IsPostBack) loop...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 30 '07 #4

Dear Mark,

Code on the first page:

Protected Sub btnCheckOut_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnCheckOut.Click
Response.Redirect("CheckOut.aspx")
End Sub
Second page:
Partial Class CheckOut
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim myCustomer As New Customer
If Session("Customer") IsNot Nothing Then
Me.txtFirstName.Text =
Session("Customer").Firstname()
Me.txtLastName.Text =
Session("Customer").LastName()
Me.txtMail.Text =
Session("Customer").Email()
End If
End Sub

Protected Sub btnShopping_Click(ByVal sender As Object, ByVal e
As System.EventArgs) Handles btnShopping.Click
If Session("Customer") Is Nothing And Page.IsValid Then
Dim myNewCustomer As New Customer
myNewCustomer.FirstName = Me.txtFirstName.Text
myNewCustomer.LastName = Me.txtLastName.Text
myNewCustomer.Email = Me.txtMail.Text
Session.Add("Customer", myNewCustomer)
Else
Session("Customer").Firstname() =
Me.txtFirstName.Text
Session("Customer").LastName() =
Me.txtLastName.Text
Session("Customer").Email() = Me.txtMail.Text
End If

Response.Redirect("cart.aspx")
End Sub
End Class



"Mark Rae [MVP]" <ma**@markNOSPAMrae.netschreef in bericht
news:OT*************@TK2MSFTNGP05.phx.gbl...
"John Devlon" <jo********@hotmail.comwrote in message
news:ja**********************@phobos.telenet-ops.be...
>Yes, I'm using ASP.NET... And I'm checking for a particalar session
variable...

OK. For future reference, it really helps if you use the correct terms for
things, otherwise people constantly have to ask you what you really
mean...
>Every time, the second page is loaded, some information is read from the
session variable...

I just would like to know why the second time the page is visited and a
button is clicked, the values of the first time is used, and not the new
ones ...
>How can I prevent this ?

It's a little difficult to say for sure as you haven't shown any of your
code, but I'm suspecting that you've forgotten to wrap your Page_Load code
in an if (!IsPostBack) loop...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 30 '07 #5
"John Devlon" <jo********@hotmail.comwrote in message
news:Ou**********************@phobos.telenet-ops.be...
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim myCustomer As New Customer
If Session("Customer") IsNot Nothing Then
Me.txtFirstName.Text =
Session("Customer").Firstname()
Me.txtLastName.Text =
Session("Customer").LastName()
Me.txtMail.Text =
Session("Customer").Email()
End If
End Sub
As suspected, the problem is that you're running the code in Page_Load every
time the page loads, even on postback, so you're overwriting all your
changes...

If Not IsPostBack Then
Dim myCustomer As New Customer
If Session("Customer") IsNot Nothing Then
Me.txtFirstName.Text = Session("Customer").Firstname()
Me.txtLastName.Text = Session("Customer").LastName()
Me.txtMail.Text = Session("Customer").Email()
End If
End If
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 30 '07 #6

Thanx Mark,

It works great

John


"Mark Rae [MVP]" <ma**@markNOSPAMrae.netschreef in bericht
news:uy*************@TK2MSFTNGP05.phx.gbl...
"John Devlon" <jo********@hotmail.comwrote in message
news:Ou**********************@phobos.telenet-ops.be...
> Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim myCustomer As New Customer
If Session("Customer") IsNot Nothing Then
Me.txtFirstName.Text =
Session("Customer").Firstname()
Me.txtLastName.Text =
Session("Customer").LastName()
Me.txtMail.Text =
Session("Customer").Email()
End If
End Sub

As suspected, the problem is that you're running the code in Page_Load
every time the page loads, even on postback, so you're overwriting all
your changes...

If Not IsPostBack Then
Dim myCustomer As New Customer
If Session("Customer") IsNot Nothing Then
Me.txtFirstName.Text = Session("Customer").Firstname()
Me.txtLastName.Text = Session("Customer").LastName()
Me.txtMail.Text = Session("Customer").Email()
End If
End If
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 1 '07 #7

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

Similar topics

3
by: sentinel | last post by:
Hi, Wonder if anyone can help with this problem: I am using an app with several pages, using a session to track vars between the pages, and using an image map to re-direct back and forwards...
3
by: Harvey | last post by:
Hi, I try to write an asp query form that lets client search any text-string and display all pages in my web server that contain the text. I have IIS 6.0 on a server 2003. The MSDN site says...
1
by: Tim | last post by:
I am using ADP projects in MS Access 2002. I have a recurring problem that happens rarely but I don't know why. I will have code form an event procedure on a control (e.g. the "OnDoubleClick"...
4
by: RBohannon | last post by:
I'm using Access 2000. I currently have a report being generated using the results of a query by form. The form used for this query is an unbound form, frmListDialog. frmListDialog contains...
1
by: Jason Galvin | last post by:
I would like to disable the auto-populating feature (remembers form element text between post-backs) when creating a .NET form. I have succeeded in disabling auto-populate by creating my controls...
0
by: Rogelio Moreno | last post by:
Ohhhh, You are talking about web form. Sorry I was thinking about Win Form. Rogelio >-----Original Message-----
5
by: vbDavidC | last post by:
I have a form that has like 20 text boxes that are comments. When I create the textbox I add it below the previous one; eventually I run out of space on the form. I am able to resize the form but...
1
verbatim
by: verbatim | last post by:
with the following page, the dynamically generated fields are not recognized when i try to submit the form, or add more elements. when i hit my submit button, the address bar has only x1 - x5 in...
18
by: Diogenes | last post by:
Hi All; I, like others, have been frustrated with designing forms that look and flow the same in both IE and Firefox. They simply did not scale the same. I have discovered, to my chagrin,...
5
by: Ian | last post by:
I am trying to: 1. Open a form on the external database 2. Enter a value in a text box on that form I have 1 above working OK using module form “The Access Web”, the module looks like this: ...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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...

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.