Description:-
In this example we explain that how to Access
Session variable in javascript or jquery.here we describes how to Access
Session at client side in asp.net.
Sometime we have requirement in application to Access the Session variable value at clientside or in javascript or jquery.
For example if we have one Application in which we have one form like Comment page and login user can Add the comment but without postback or page load. So you have to must defined a one web method that are used for inserting comment and this method is called from the clientside like Jquery/Ajax call with one parameter username.
So how it is possible because that is the real problem that I was faced. So finally we fetch the session value in javascript and then call the web method with pass parameter like username that we already fetch it from the session variable at client side javascript.
So access session variable in javascript and pass it to method and insert the record without postback is done through below code.
Sometime we have requirement in application to Access the Session variable value at clientside or in javascript or jquery.
For example if we have one Application in which we have one form like Comment page and login user can Add the comment but without postback or page load. So you have to must defined a one web method that are used for inserting comment and this method is called from the clientside like Jquery/Ajax call with one parameter username.
So how it is possible because that is the real problem that I was faced. So finally we fetch the session value in javascript and then call the web method with pass parameter like username that we already fetch it from the session variable at client side javascript.
So access session variable in javascript and pass it to method and insert the record without postback is done through below code.
there are multiple ways to access Session variable at client side at javascript as follows
Restrict the size of File when Uploaded How to Restrict the size of File when uploaded by user
Dynamically Read/Write File in asp.Net How to Read Write File in Asp.Net using C#