Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
1.29/5 (3 votes)
See more:
i m getting this error ..

Cannot convert object of type \u0027System.String\u0027 to type \u0027System.Collections.Generic.IDictionary`2[System.String,System.Object]\u0027","StackTrace":"



how to solve this in .js file
Posted
Comments
Kornfeld Eliyahu Peter 16-Jun-14 7:37am    
It seems you have logical error in your code so you try to initialize a variable of type dictionary with a string, however without showing us your code it impossible to help you out...
Naina2 16-Jun-14 8:19am    
var leadid = ctrl.find('.leadid').val();
var enquiry = ctrl.find('#enquiry').val();
var desc = ctrl.find('#category_desc').val();
var category = ctrl.find('.ddlStage option:selected').val();

var sdata = "{";
sdata += "leadId:'" + leadid + "',";
sdata += "enquiry:'" + enquiry + "',";
sdata += "desc:'" + desc + "',";
sdata += "category:'" + category + "'";
sdata += "}";
$.ajax({
url: 'webservices/LeadManagement.asmx/UpdateLeadmanage',
type: "POST",
dataType: 'json',
cache: false,
contentType: 'application/json; charset=utf-8',
data: JSON.stringify(sdata),
success: function (result) {
alert(result.d);
if (result.d.length > 0 ) {
message.ShowStaticMessage("Lead Detail Update sucessfully", "message");

}
else {
message.show(result.d, 'error');
}
}
});


this is my code
Kornfeld Eliyahu Peter 16-Jun-14 8:22am    
This is a JavaScript code sample, where the error is from some .NET code - probably this 'webservices/LeadManagement.asmx/UpdateLeadmanage'...So your code has no use for our case, please add the relevant code!
Naina2 16-Jun-14 8:54am    
this is the webmethod

public string UpdateLeadmanage(int leadId, string enquiry, string desc, string category)
{
DTOLeadManage dto = new DTOLeadManage();
dto.LeadId = leadId;
dto.Enquiry = enquiry;
dto.category_description = desc;
dto.category = category;
DALLeadManagement dal = new DALLeadManagement();
return dal.UpdateLeadmanage(dto);

}
Naina2 16-Jun-14 8:54am    
this is the proc


public string UpdateLeadmanage(DTOLeadManage dto)
{

string result = string.Empty;
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "proc_update_lead";
cmd.Parameters.AddWithValue("@lead_id", dto.LeadId);
cmd.Parameters.AddWithValue("@enquiry", dto.Enquiry);
cmd.Parameters.AddWithValue("@category_desc", dto.category_description);
cmd.Parameters.AddWithValue("@category", dto.Category_Id);
result = "error";
try
{
con.Open();
cmd.ExecuteNonQuery();

}
catch (Exception ex)
{
throw ex;
}
finally
{
con.Close();
}
return result;
}

Try this :

JavaScript
$.ajax({
url: 'webservices/LeadManagement.asmx/UpdateLeadmanage',
type: "POST",
dataType: 'json',
cache: false,
contentType: 'application/json; charset=utf-8',
data: "{'leadId':"+ leadid +",'enquiry':'"+enquiry+"','desc':'"+desc+"','category':'"+category+"'}",
success: function (result) {
    alert(result.d);
},
error: function(err){ alert('error'); }
});
 
Share this answer
 
v2
Dear,

Replace below line

Old :
data: JSON.stringify(sdata),
sdata += "leadId:'" + leadid + "',";

NEW
data: sdata,
sdata += "leadId:" + leadid + ",";
 
Share this answer
 
v5

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