views:

45

answers:

1

i have a java script dictionary. its dictionary<string,dictionary<string,string>> if it is helpfull. i cant pass it to controller class using jquery ,ajax is ther any way to do that?

<script language="javascript" type="text/javascript">
 var dictionary = {};
  var props = {};
props["test1"]="test1";
props["test2"]="test2";
props["test3"]="test3";
dictionary["test"]=props;

function SaveForm() {
 $.ajax({
     type: 'POST',
     url: '/Home/SaveForm',
     data: { formName: $('#formName').val(),  dics: dictionary },
     //contentType: 'application/json'
     dataType: 'json'

 });
}


</script>


public void SaveForm(  Dictionary<string,<string,string>>dics)===> dics is null always
+1  A: 

Some useful pointers here:

How do I pass a Dictionary as a parameter to an ActionResult method from jQuery/Ajax?

cxfx
i used it but by this line bindingContext.Model = new JsonDictionary()in public class JsonDictionaryModelBinder : IModelBinder { #region IModelBinder Members public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { if (bindingContext.Model == null) { bindingContext.Model = new JsonDictionary(); }i will face with this errorThis property setter is obsolete, because its value is derived from ModelMetadata.Model now.
adrakadabra
Try here for tweaks to get it working in MVC2 - http://stackoverflow.com/questions/1531776/this-property-setter-is-obsolete-because-its-value-is-derived-from-modelmetadat
cxfx