Wee Bubba Posted October 5, 2005 Posted October 5, 2005 hello there. i need to persist the form values of a particular web page so that if a user gets timed out then i can repopulate it when they return to that page. likewise, if a user fills half the form in then decides to browse a different page before returning later on, then i will also need to remember the values. i dont believe that i can trap either of these events with a postback so at the moment i am thinking the best solution is to keep storing the form values inside a cookie every time the javascript 'onunload' event handler fires. i can then repopulate from the cookie when a user comes back to the page. i can enforce that cookies is on for users of my application as it has a private user base so thats not a problem. however ive heard that certain popup stopper applications block this event handler so its perhaps not the best way. is there a better way? Quote
JTDPublix Posted October 5, 2005 Posted October 5, 2005 You could store each value in a cookie when each form element loses focus. I believe you could use the onBlur event to tell when the user has finished with the element and its lost focus. Quote
TheWizardofInt Posted September 6, 2006 Posted September 6, 2006 Create a class called globVars Post this code into it: Public Class globVars #Region "Private Variables" Protected Shared Inst As globVars = Nothing 'this is the self-setting key to individualize globVars Protected mIdentity As System.Security.Principal.WindowsIdentity 'this is the back-up identity determiner #End Region #Region "Private Functions" Private Sub New() mIdentity = System.Security.Principal.WindowsIdentity.GetCurrent 'on every new instance, reset the identity End Sub #End Region #Region "Read Only Properties" Public ReadOnly Property GetIdentity() Get Return mIdentity End Get End Property #End Region #Region "Public Functions" Public Shared Function GetInstance() As globVars If Inst Is Nothing Then Inst = New globVars End If Return Inst End Function Public Shared Sub Setup() Inst = New globVars End Sub #End Region In your global.asax, in the StartSession, invoke the class like this: Dim glob as globVars glob = globVars.getinstance glob.Setup Now set every variable you need to pass as a property in the new public property Private mUser As String Public Property sUser() As String Get Return mUser End Get Set(ByVal value As String) mUser = value End Set End Property You can now set a value for sUser in one page and retrieve it in the next The class DOES tend to persist when you kill the site, because SessionEnd and ApplicationEnd don't always work in .Net. Therefore you re-invoke it with every session Other sessions will have no affect on your class, however, as is it is invoked against the windows identity Quote Read the Fovean Chronicles Because you just can't spend your whole day programming!
Administrators PlausiblyDamp Posted September 7, 2006 Administrators Posted September 7, 2006 If you cannot rely on the page being posted back then your solution is probably the best. If someone is using some form of pop-up / cookie blocker then there is nothing you can do except 'educate' them to either allow cookies from your app or just live with the problem. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Gill Bates Posted September 8, 2006 Posted September 8, 2006 You can also perform an XmlHttp request in the background and post the form elements back to the server. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.