问题描述:

I'm trying to open a modal popup in an ASP.NET MVC3 application, and pass it some parameters.

The popup contains a view defined in a file called SearchArea.cshtml

So, here is what I wrote :

My view :

var coordinates = [];

//push some data in coordinates

//coordinates looks like : coordinates[0] = 45.25489, coordinates[1] = 5.14975, etc...

$("<div></div>")

.addClass("dialog")

.appendTo("body")

.dialog({

title: "TEST",

close: function () { $(this).remove(); },

modal: true,

height: 400,

width: 600,

left: 0

}).load('@Url.Action("Show", "SearchArea")', {'coordinates' : JSON.stringify(coordinates) });

My controller

public ActionResult Show(string coordinates)

{

List<Single> searchArea = JsonConvert.DeserializeObject<List<Single>>(coordinates);

return View(searchArea);

}

However, this is what I obtain :

When I debug step-by-step, searchArea has good values, so I think serialization / deserialization are OK. The view that should be loaded is OK too, I tried to display it and no error occurs.

Where am I wrong ? I've seen this , this and a lot of others, but I can't correct my mistakes... Can someone help me ?

网友答案:

Finally found a solution yesterday.

Instead of stringified an array, I stringified coordinates.Join(','). This works, but this is ugly. So I'm working on created an model containing all wanted fields, then pass it to my view. It should work, I tried with dummies values and it seems to work

相关阅读:
Top