Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
120
How do i access session variable from client side java
posted

Gday, can anyone help show me how to access session variable from java script. i have tried as in code below but no luck.

 

function wdgRegister_Selection_RowSelectionChanged(sender, eventArgs)

{

var vendor = eventArgs.getSelectedRows().getItem(0).get_cell(4).get_value();

    <%Session("RegisterId") = vendor; %>

}

// -->

The above code is not working. can any one help. Thanks

  • 29417
    Suggested Answer
    Offline posted

    Hello Ikenna, 

    Thank you for posting in our forum.

     

    Session variables can be accessed on the client side. For example you could check the value by calling:

     

          alert('<%=Session["RegisterId"] %>');

     

    Anything between the "<%" and "%>" runs at the server so it will evaluate the current value of the session. However since it runs on the server it won’t be aware of any client side defined variables.

     

    Ultimately the session only exists on the server side so I would advise you to not attempt to set it directly on the client. Instead use a hidden field to store the values you need and then access the hidden field value on the server side from where you can store it in session if needed.

     

    Let me know if you have any questions or concerns.

     

    Best Regards,

    Maya Kirova

    Developer Support Engineer

    Infragistics, Inc.

    http://ko.infragistics.com/support