Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC4 sending model propert id to controller class
    primarykey
    data
    text
    <p>How to send id of a model property Name to Controller class in an MVC4 application</p> <pre><code> public class{ public Name{get;set;} } </code></pre> <p>For Accesing name using id of that property Update: Here if change Name using jquery at runtime i want to send the changed name id to the controller class</p> <p>UPDate: This is my VIew</p> <pre><code>&lt;script type="text/javascript"&gt; $(function () { $('.editor input').blur(function () { $(this).hide(); $(this).closest('p').find('label').html($(this).val()).show(); }); $('.editor label').click(function () { $(this).hide(); $(this).closest('p').find('input').show(); }); }); </code></pre> <p></p> <pre><code>@using (Html.BeginForm("Homepage", "Home", FormMethod.Post)) { &lt;div class="editor"&gt; &lt;p&gt; @Html.LabelFor(x =&gt; x.Name, Model.Name) @Html.EditorFor(x =&gt; x.Name) &lt;input type="submit" value="OK" /&gt; &lt;/p&gt; &lt;p&gt; @Html.LabelFor(x =&gt; x.Company, Model.Company) @Html.EditorFor(x =&gt; x.Company) &lt;input type="submit" value="OK" /&gt; &lt;/p&gt; &lt;p&gt; @Html.LabelFor(x =&gt; x.City, Model.City) @Html.EditorFor(x =&gt; x.City) &lt;input type="submit" value="OK" /&gt; &lt;/p&gt; &lt;/div&gt; &lt;input type="submit" value="OK" /&gt; } </code></pre> <p>This is my model</p> <pre><code> public class Details { public string Name { get; set; } public string Company { get; set; } public string City { get; set; } } </code></pre> <p>This is my COntroller methods</p> <pre><code> public ActionResult Homepage(Details d) { d.Name = "Rakesh"; d.Company = "TCS"; d.City = "DElhi"; return View(d); } [HttpPost, ActionName("Homepage")] public ActionResult Indexof(Details d) { return View(d); } </code></pre> <p>Here i am editing and sending data to the controller but my problem is when i click on Rakesh for example and change the name then i need to click button twice then only the changed data is sent to the controller class</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload