Ajax.ActionLink, how to send the selected object in the partial view? asp.net mvc -


I think this is a noob question, but here it comes:

There is a list:

  & lt;% foreach (Miscellaneous items in the model) {%> & Lt; TR & gt; & Lt; TD & gt; & Lt;% = Html.Encode (item.code)% & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt;% = Html.Encode (string.format ("{0: g}", item.date))%> & Lt; / TD & gt; & Lt; TD & gt; & Lt;% = Html.Encode (item.category)%> & Lt; / TD & gt; & Lt; TD & gt; & Lt;% = Html.Encode (item.description)% & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt;% = Html.Encode (string.format ("{0: F}", item.price))%> & Lt; / TD & gt; ......}  

and after all, a partial view (in the same page):

   

I am Ajax How to use thenicklink, so that when I click on the details of a product, the product will be plugged in from the bottom of the page to a partial view? I tried some combination with UpdateTargetId = "productForEdit" , but I could not find any success.

Its purpose is to have a quick editing tool in the page.

I think this should work:

  & lt ; Td> & Lt;% = Ajax.ActionLink (Html.Encode (item.description), / * link text * / "GetProduct", / * action name * / "product", / * controller name * / new {productCode = Model. Code}, / * route value * / new AjaxOptions () {InsertionMode = InsertionMode.Replace, UpdateTargetId = "productForEdit"})%> & Lt; / TD & gt;  

It expects product controller with an action called GetProduct , which contains the parameter productcode Is this "product / editing" view returned to this verb? You can also pass the whole product as a parameter in the action method, but it does not change anything from the basic idea. Good luck!


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -