[RESOLVED]What is the Best Way to Pass Client-Side Info to Other Pages (In Same Application)

I have some information that is obtained from the client (Date().getTimezoneOffset()) that I need to save from the application Home page and then make available to all the other pages in the application. The other pages use this information to localize dates
before they are displayed in reports.

What I am doing now is obtaining the information on the initial page load, passing as an argument for postBack and then on postBack saving that value in a Session variable in Page_Load. It works but it seems like a kludge…

I could also add it as a QueryString parameter to the page, this also seems prone to error — someone bookmarks a URL and then later runs the page from a different time zone…

I tried saving the information in a Hidden variable in an UpdatePanel but I was never able to get this to work.

Any thoughts or suggestions would be appreciated!

Session Variables work throughout the users session on every page. Session("Date") = Date().getTimezoneOffset() to set it and then check,

If Not IsNothing(Session("Date")) then

 ‘ user date

End if

You can also use cookies 

I thought Session was a server side component and that you could not set a Session variable from the Client. If I am wrong, how do you set a Session variable from the client?

You can use eaither hidden fields and pass them from page to page or use cookies.

Hi,

On pageload you can call a pagemethod in the background and set session variable-

http://delicious.com/anupdg/session+pagemethod

I guess I am not being clear — Once I get control back to the server I do not have any problem setting the Session variable. The problem I am having is getting the information from the client to the server without kluding a postback event.

In another application I force the user to click a button to do this, and it works. I was just looking for a cleaner solution.

If you want to have the information available on another page there WILL be a postback event (or should be) to redirect to that page. In the postback you can set the session variable. Now if you prefer you can set a cookie using javascript and use THAT http://www.w3schools.com/js/js_cookies.asp

MJEdelman

I guess I am not being clear — Once I get control back to the server I do not have any problem setting the Session variable. The problem I am having is getting the information f

If you use the approach I have shown you need not to do a postback or add a buttonclick.

asteranup

Hi,

On pageload you can call a pagemethod in the background and set session variable-

http://delicious.com/anupdg/session+pagemethod

asteranup

MJEdelman

I guess I am not being clear — Once I get control back to the server I do not have any problem setting the Session variable. The problem I am having is getting the information f

If you use the approach I have shoun you need not to do a postback or add a buttonclick.

I am not seeing the approach you referred to in your first message. When I click on the link it does not provide me a reference to something that I can map to what I am trying to do. I would appreciate it if you could be more specific with your solution.

Hi,

May be you have some network restriction. You can check the following fron the list I have given-

http://forums.asp.net/p/1708139/4544368.aspx/1?Re+Jquery+session

Leave a Reply