开发者

How to add a view for the json result in asp.net mvc?

开发者 https://www.devze.com 2022-12-28 13:23 出处:网络
I retu开发者_Python百科rnedjson result from a controller but how can i add a view that uses this json result..

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

0

精彩评论

暂无评论...
验证码 换一张
取 消