0

I have a vb.net aspx page that i need to assign a session variable inside of javascript

if i do the following

var baz ="<%=Session("User")%>";
alert(baz);

the alert i receive is the class name

 "TheName.WebFramework.Security.AdvanceUser"

i need a nested value of this session , and have no idea how to do this in vb

i do however know how to do this in C# / generic http handler

 ...
 public void ProcessRequest (HttpContext context) {
    IAdvanceUser user = context.Session["User"] as IAdvanceUser;
 ... 
    var ID = user.EntityID

and of course in php, RoR , ColdFusion, ect

I have tried this but it failed miserably

var baz ="<%=Session("User").("EntityId")%>";
alert(baz);

any ideas?

1 Answer 1

1

Try this: use CType(fromObjectHere, toObjectHere)

var baz ="<%= CType(Session("User"), AdvanceUser).EntityID %>";

Update

You might need to type the full name TheName.WebFramework.Security.AdvanceUser or import the namespace

<%= CType(Session("User"), TheName.WebFramework.Security.AdvanceUser).EntityID %>
Sign up to request clarification or add additional context in comments.

6 Comments

got error Object reference not set to an instance of an object.
@worthycaesar That means the object in session is not IAdvanceUser. From your question it should be AdvanceUser. Check my update
Type 'AdvanceUser' is not defined, guarantee its close though
You might need to type the full name TheName.WebFramework.Security.AdvanceUser or import the namespace
<%= CType(Session("User"), TheName.WebFramework.Security.AdvanceUser).EntityID %>
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.