kala-tamin ASP.Net MVC (1) - how can I pass JSON to view but not as separate ajax call


ASP.Net MVC (1) - how can I pass JSON to view but not as separate ajax call



I have some data that I want to pass into the View (.aspx page) in JSON format.

I could add an async ajax call and load it that way, but since I have the data upfront, why not just dump it into the view.

I could pass a C# object as the model and in Javascript manually iterate through it to fill out a Javascript object, but this seems like something someone has done before and there may well be a tool to do it already...

Thanks in advance, Chris


How to make pages automatically use https when using asp.net mvc 2.0

1:

is it possible to bind JQGrid OnSelectRow using Live?
You could serialise it using System.Web.Script.Serialization.JavaScriptSerializer.. Add new row(s) dynamically in emtpy table using telerik grid in ASP.NET MVC
ViewData["JSONData"] = new JavaScriptSerializer().Serialize(myObject); 
You could then render this into a hidden field or wherever on the view.. ASP.NET MVC Routing Strange or Unexpected Behavior
Which to learn: ASP.NET MVC or ASP.NET [duplicate]Localizing the fields / attributes on the AccountModel for ASP.NET MVC

2:

Default ASP.NET MVC 2 web pages do not work in IE6
You could convert the data into the JSON using Json.net and then pass the Json.net object to the view model as a string.. Have jqGrid use different page to view a row
viewModel.JsonToUse = JsonConvert.SerializeObject(object).ToString(); // Or build the Json up manually using a JOBject.  return View("ViewName", viewModel); 


66 out of 100 based on 41 user ratings 756 reviews