开发者

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜