1

I returned 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...

1
  • Just like any other view in ASP.NET MVC project. Then a bit of JavaScript in that view to process the json. Commented Apr 30, 2010 at 12:22

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.