how to pass and retrieve session using jquery

Posted by Klbaiju under jQuery on 4/1/2014 | Points: 10 | Views : 1106 | Status : [Member] | Replies : 2
Hi,i want to pass and retrieve session using jquery.following is my code

$('#btnlogin').click(function () {
//alert("test");

var uname = $('#txtuname').val();

var pword = $('#txtpword').val();

var ID = 'uname=' + uname + '&pword=' + pword;
// alert(ID);
if (uname.length > 0 && pword.length > 0) {
$.ajax({
type: "GET",
contentType: "text/html;charset=utf-8",
url: "LoginProcess.aspx",
data: ID,
success: function (data) {

if (data == "CMP") {
$('#lbltext').val('');
window.location.href = "Admin/Admin.aspx";
Session=uname

}
}
});
I want to retrieve the session in Admin.aspx.
how it is possible.

Regards
Baiju




Responses

Posted by: Allemahesh on: 4/1/2014 [Member] [MVP] Silver | Points: 25

Up
0
Down
See the below link:-

http://stackoverflow.com/questions/19701658/how-to-call-c-sharp-method-in-jquery

Happy coding.

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: A2H on: 4/2/2014 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi,
I guess your requirement is to pass the username value to Admin.aspx page. if that is the case then you can use QueryString to pass value between pages.

Your Modified Code:
$('#btnlogin').click(function () { 

//alert("test");

var uname = $('#txtuname').val();

var pword = $('#txtpword').val();

var ID = 'uname=' + uname + '&pword=' + pword;
// alert(ID);
if (uname.length > 0 && pword.length > 0) {
$.ajax({
type: "GET",
contentType: "text/html;charset=utf-8",
url: "LoginProcess.aspx",
data: ID,
success: function (data) {

if (data == "CMP") {
$('#lbltext').val('');
//Here you can pass the value using Query string
window.location.href = "Admin/Admin.aspx?userName=" + uname;
//Session=uname

}
}
});


Admin.aspx(Receiver Page)
You can read the value passed through query string like given below
//Read the values from Query string

string value = Request.QueryString["userName"].ToString();


Hope this helps.

Please mark my reply as answer if it helps to resolve your problem

Thanks,
A2H
My Blog

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response