getting object property from session var in HTML
I have a user object that gets instantiated / initialized on login.
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?
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..
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center