data disappearing problem on the forms when navigate

G

Guest

Hi all,
the data disappearing problem occurs to all my controls even my regualr web
control like asp:textbox, when I click back button in web browser from second
page to first page and then click continue button on the first page to second
page again, all the data entered , even in web server control(not user
controls defined by myself.) all disappear.
What's going on. I thought dealing with .net should be much easier, did I
miss something???
 
G

Guest

Hi all,
I think I got it in one way. But I don't think it the best way.
in the pag_load, I just check if the session is empty or not. If not
I just reload the session variables to the controls again.
Can someone come with better solution? I am afraid that my design is awkward.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim ctrlarr(5) As PeopleInfo
If Not Session("ctrlarr") Is Nothing Then
ctrlarr = Session("ctrlarr")
If ctrlarr(0).FirstName <> "" Then
Peopleinfo0.FirstName = ctrlarr(0).FirstName
Peopleinfo0.LastName = ctrlarr(0).LastName
Peopleinfo0.SSN = ctrlarr(0).SSN
End If
End If


End Sub
 
S

Steven Cheng[MSFT]

Hi Betty,

As for the data disappearing problem when swtiching page through the
browser's back/forward button, it's the expected behavior because different
pages are displayed in browser through different http requests to server.
When we use back button of browser, it may display the previous page with
input fields filled since the page is retrieved from cache. However, when
go forward again, the page is requested again from serverside, then the
input fields on the page will be the initial state(empty). And for such
scenario I think your current approach that using session state to store
the temp data is reasonable, and the only drawback is that we have to clear
the session data as soon as possible(right after we finish using them) so
as to avoid occupying too much server resource...

BTW, if you feel it possible that we put the wizard/multiple steps like
user interface in single page, you can consider my suggestion on using the
ASP.NET 2.0's wizard control as mentioned in your another thread.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
G

Guest

how Yes, Steven. I will consider using that in the next project. I definitely
think it's better way. By the way, how to clear session in asp.net, is it the
same as in asp.
Thank you for your great much. You gave me many good answers to my several
posts.
 
S

Steven Cheng[MSFT]

My pleasure Betty :)

For Session State, we have the following pattern to clear values in it:

1. When a certain item in it is no longer needed, we can just clear it by
assign that entry to null , e.g:

Session["key1"] = null;

then, that entry's referenced object will be ready for GC(if there is other
live reference to it).

2. If you want to clear all the referenced objects in the current User's
Session, you can call HttpSessionState.Clear method:

#HttpSessionState.Clear Method
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwebsessionstat
ehttpsessionstateclasscleartopic.asp?frame=true

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top