c# - ASP.net MVC passing data from Partial View Back To the Main -
i dynamically loading partial view using ajax, textboxes entry on same page main data list, without having reload main data list each time edit made. data list shown, user can click on entry load textbox, in view mode, after can select edit edit entry. issue have edit button in main view, , id of item want edit in partial view.
my main view
@model presentationlayer.models.hr.equipmenttypes @{ viewbag.title = "equipment"; } @section script{ <script type="text/javascript"> $.ajaxsetup({ cache: false }); </script> } <h2>links</h2> <h3>all links</h3> <table> <thead> <tr> <td>name</td> </tr> </thead> @foreach (var equipmenttype in model.equipmenttype) { <tr> <td>@ajax.actionlink(equipmenttype.name, "index", "link", new { id = equipmenttype.id }, new ajaxoptions { httpmethod = "get", updatetargetid = "linkedit", insertionmode = insertionmode.replace })</td> </tr> } </table> @html.partial("linkedit", model.typetoedit) @ajax.actionlink("edit", "edit", "link", new { id = equipmenttype.id }, new ajaxoptions { httpmethod = "get", updatetargetid = "linkedit", insertionmode = insertionmode.replace })
my partial view
@using presentationlayer.models.hr @model presentationlayer.models.hr.equipmenttype <div id="linkedit"> @using (html.beginform()) { @html.validationsummary(true) <fieldset> <legend>edit</legend> @if (model.islocked == true) { @html.textboxfor(model => model.name) @html.hiddenfor(model => model.id, new {id="hiddenid"}) } else { @html.textboxfor(model => model.name, new { disabled = "disabled", @readonly = "readonly" }) } <p> <input type="submit" value="save" /> </p> </fieldset> } </div>
i need able hiddenfor data out , able push id in @ equipmenttype.id part of ajax edit call, trying use tempdata did after, didn't initally understand how temporary tempdata was. requirement edit buttons in main layout, seemed impossible do.
i new asp.net mvc, been coding asp.net few years , works on mvc within java, has left me @ bit of stop. hope have given enough information, if not let me know , try expand.
thanks
you edit button outside of foreach loop. won't id @ all.
place edit button within loop value of equipmenttype.id. each row have it's own edit button. that's normal thing in tabular data edit function.
Comments
Post a Comment