Hi,
I want to add key value pair like hashtable in jquery.
following is my code for adding key value pair to hashtable
$('#btnview').click(function (e) {
e.preventDefault();
var vc = $('#ContentPlaceHolder1_txtvoucherid').val();
var type = $('#ContentPlaceHolder1_txtvtype').val();
var hashtable = {};
hashtable['tablename'] = "vchr";
hashtable['type'] = type;
hashtable['vchrid'] = vc;
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "CashPaymentVoucher.aspx/dp",
data: "{'id':'"+hashtable+"'}",
dataType: "json",
success: function (data) {
}
});
});
and following is the webmethod in the next page
[WebMethod]
public static VoucherDetails[] dp(Hashtable id )
{
List<VoucherDetails> details = new List<VoucherDetails>();
i know this is wrong .and showing error .
my requirement is to pass hashtable to another page
like this
BAL obj=new BAL();
DataSet ds = obj.Getsearch(id);
return details.ToArray();
}
i know this is wrong .and showing error .
my requirement is to pass hashtable to another page
like this
DataSet ds = obj.Getsearch(id);
here id is the hashtable from aspx page
error showed was
{"Message":"Cannot convert object of type \u0027System.String\u0027 to type \u0027System.Collections
.Hashtable\u0027","StackTrace":" at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal
(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object\u0026 convertedObject
)\r\n at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain(Object o, Type type
, JavaScriptSerializer serializer, Boolean throwOnError, Object\u0026 convertedObject)\r\n at System
.Web.Script.Services.WebServiceMethodData.StrongTypeParameters(IDictionary`2 rawParams)\r\n at System
.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary`2 parameters
)\r\n at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData
methodData, IDictionary`2 rawParams)\r\n at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall
(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.InvalidOperationException"
how to solve this
regards
Baiju