DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  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..

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links