Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
clientside Code

JavaScript
<script>
var obj = [];
jQuery.support.cors = true;
$(document).ready(function () {
$("#btnLoginobj").click
(
function () {

var StaffCode = $("#txtValue1").val();
var Password = $("#txtValue2").val();
$.ajax({
url: "http://localhost:9320/api/UpdateKYC",
type: "Get",
data: JSON.stringify([StaffCode,Password]),
success: function (data) {
$('#usersection').empty();
for (var i = 0; i < data.length; i++) {
obj[i] = new Object;
obj[i].CenterCode = data[i].CenterCode;
obj[i].LoanCode = data[i].LoanCode;
obj[i].ClientCode = data[i].ClientCode;
obj[i].ClientName = data[i].ClientName;
obj[i].DateApproved = data[i].DateApproved;
obj[i].LoanStatus = data[i].LoanStatus;

$('' + data[i].CenterCode + '' + obj[i].LoanCode + '' + obj[i].ClientCode + '' + obj[i].ClientName + '' + data[i].DateApproved + '' + obj[i].LoanStatus + '').appendTo("#usersection");
}
},
error: function (msg) { alert(msg); }
});
}
);

});



ASP.NET
<asp:TextBox ID="txtValue1" runat="server" />
<asp:TextBox ID="txtValue2" runat="server" />
<input type="button" id="btnLoginobj" name="btnLoginobj" value="login with object" />



server side

C#
public List GetDetail(List val)
{
List<clientliststructure> ObjclientList = new List<clientliststructure>();
LoginSructure objLoginStructure=new LoginSructure();
objLoginStructure.StaffCode =val[0];
objLoginStructure.Password = val[1];
try
{
string connectionstring = ConfigurationManager.ConnectionStrings["ConnectionStrig"].ConnectionString;
SqlConnection con = new SqlConnection(connectionstring);
SqlCommand cmd = new SqlCommand("select BranchCode from Staff where StaffCode='" + objLoginStructure.StaffCode + "' and Password='" + objLoginStructure.Password + "'", con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
BranchCode = reader.GetString(0);
}
reader.Close();
cmd.Dispose();
con.Close();
ObjclientList = new MapClientDatatoModel().Mapclientlist(BranchCode);
return ObjclientList;
}
catch (Exception ex)
{
return ObjclientList;
}

}


Description
when pass data(staffcode,password) from client side then server side not receive data(satffcode,password). actually i send data staffcode and password and get client list from server
Posted
Updated 7-Jun-15 19:32pm
v2

1 solution

var stringArray = new Array();
    stringArray[0] = $("#txtValue1").val();
    stringArray[1] = $("#txtValue2").val();
    var postData = { values: stringArray };

    $.ajax({
        type: "GET",
        url: "/Home/GetDetails",
        data: postData,
        success: function(data){
            alert(data.Result);
        },
        dataType: "json",
        traditional: true
    });


public void GetDetails(List<String> values)
{
    Result = String.Format("Fist item in list: '{0}'", values[0]);
}
 
Share this answer
 
v3
Comments
amt kumar rai 8-Jun-15 8:37am    
GetDetails(List<string> values) recive null value

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