Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,


In my web application using javascript i got the selected item from a list. Now i have a partial view . i want to display this partial view with selected data when i click one item in a list.currenlty i am using webapi concept and knockout.js.plz help me
Posted
Updated 5-Aug-13 21:46pm
v2

1 solution

Remember - partial view stayed on server.

so look into retrieving action result using ajax.

C#
<div id="container">
    @Html.Partial("_IndexPartial")
</div>

@Ajax.ActionLink("Change data", "Index", "Home", new {}, new AjaxOptions{UpdateTargetId = "container"}, new {someparam = "somevalue"}) 


http://msdn.microsoft.com/en-us/library/system.web.mvc.ajax.ajaxextensions.actionlink(v=vs.108).aspx[^]

You can also look into loading json packet through web api and render it on client using template (if you are using knockout, kendo, jquery-templates or similar library) etc.

In fact goal can be achieved in number of ways - up to you.
 
Share this answer
 
Comments
josh-jw 6-Aug-13 3:44am    
i am using knockout js.so how can i do this functionality?
Vyacheslav Voronenko 6-Aug-13 3:48am    
1. Read knockoutjs manuals
http://knockoutjs.com/documentation/json-data.html
2. Implement WebApi method returning json
3. Capture output, set to model.
4. Enjoy.
josh-jw 6-Aug-13 4:46am    
In my case i am displaying item selected from the list. i am able to get the selected item. but dont know ,how to call a partial view and bind this data
Vyacheslav Voronenko 6-Aug-13 4:48am    
Either you create jsFiddle to localize concrete problem, or read documentation with examples on knockout & MVC4. This is something that can be resolved by documentation studying. I have provided you with clues.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900