getting object property from session var in HTML


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: getting object property from session var in HTML

  1. #1
    Join Date
    Dec 2004
    Posts
    12

    getting object property from session var in HTML

    Hello,

    I have a user object that gets instantiated / initialized on login.

    I have a javascript function that needs to utilize some of the properties of that user object.

    In the HTML am trying to figure out how to take that session var / object called currentUser and get the FirstName property.

    I tried: myFunction('<%= Session["currentUser"].FirstName %>');

    ... and I get this error:
    CS0117: 'object' does not contain a definition for 'FirstName'

    I know that the object exists in the session, the property exists in the object because I can write to a label from the code-behind without any trouble.

    What else might be going on here?

    tx

    k

  2. #2
    Join Date
    Sep 2004
    Location
    Malaysia
    Posts
    4
    I think the object should be casted to the real type first before accessing the property. Assuming that the class for user is named UserInfo, then you should do this ((UserInfo)Session["currentUser"]).FirstName. You might need to supply the full name of the class, including the namespace..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center