An important thing to remember is that session objects run on the
SERVER, while javascripts run on the CLIENT (Browser).  The javascript
can only interact with objects actually on the page or objects created
by other client-side scripts, they cannot directly interact with
server objects such as session variables.

So, no, you cannot directly access a session object from javascript.

If you want to expose the values in a session object (or any server
side variable) to your client-side script, you need to do so by
generating/filling values into html controls or xml islands on the
page.  You could also dynamically produce javascript when the page
loads to produce objects you can access via javascript.

Of course, once you have let the user update the objects on the
client, you need to access the values on the server.  The most
straightforward method is to simply post the form back and let the
server read through the values in the html controls.  You could also
get very fancy and call the server from the browser using web services
methods, but that's a discussion for another day.

 
On 5/17/05, Eva Li <[EMAIL PROTECTED]> wrote:
> Objects in session can be easily accessed across aspx pages.
> Here is how I store and access my objects:
> 
>      Object myObject = Object (some thing).
>     Session["MyObj"] = myObject
> 
> This object can be accessed in another page (code behind):
> 
>       Object myObject = Session["MyObj"] as Object
> 
> Questions: Can I access this object stored in Session from my
> JavaScripts/Functions in my aspx page? Or is there any alternative?
> Here, I'd like to communicate between my aspx and aspx.cs accessing
> same object.
> 
> Thanks!
> 
> Eva
> 
> 
> [Non-text portions of this message have been removed]
> 
> Yahoo! Groups Links
> 
> 
> 
> 
> 


-- 
Dean Fiala
Very Practical Software, Inc
http://www.vpsw.com


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to