How to add a view for the json result in asp.net mvc?
I retu开发者_Python百科rned json result from a controller but how can i add a view that uses this json result..
public class MaterialsController : Controller
{
ConstructionRepository consRepository = new ConstructionRepository();
public JsonResult Index()
{
var materials = consRepository.FindAllMaterials().AsQueryable();
return Json(materials);
}
}
How to add a view to this? Any suggestion...
If are returning JsonResult view will not be attached to it. It will be pure Json that will be sent to the browser.
However you can use Asp.Net ClientSide template or JQuery Client Templates to render view using this Json. An example
http://jtemplates.tpython.com/
http://weblogs.asp.net/dwahlin/archive/2009/05/03/using-jquery-with-client-side-data-binding-templates.aspx
精彩评论