Click here to Skip to main content
15,886,104 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello...

How to session value set using Jquery in asp.net.?

I have total work on client side and i have set session value in asp.net.?

What i to do..?

Or any other option available to save session value using ajax post in asp.net??
Posted

1 solution

You would call $.ajax()[^], which is jQuery's easy way of calling a web service.

Then you'll need a WebMethod that will take 2 Strings, the Session variable name and the session value you want to set it to.

Also, make sure to enable the session in your webmethod, like this:
C#
[WebMethod(EnableSession = true)]
because by default, you won't be able to access the session without that.
 
Share this answer
 
Comments
Abhai Oza 30-Mar-15 12:23pm    
But i have set session in ajax call time.
Just eg:-
$.ajax({
url: '<%=Config.VirtualDir %>contact-us.aspx?submitform=y',
data: $('#frmContact1').serialize(),
type: 'POST',
success: function(resp) {
if(resp=="InvalidCaptcha")
{

// Session value set
}

}
});

WWhat to do..??
ZurdoDev 30-Mar-15 12:44pm    
I don't understand. If you have this, then debug it. It's calling a webpage, not a webservice, but that can still work.
ZurdoDev 31-Mar-15 7:35am    
I don't think you understand what your jquery is doing then. Just look at your jquery, you can see it there. The uri is pointing to contact-us.aspx. That's a webpage. Probably not the right page for setting a session variable though.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900