Note that there are some explanatory texts on larger screens.

plurals
  1. POEmpty model value when happen HttpPost method
    primarykey
    data
    text
    <p>I have partial view for deleting <em>user</em>. I use bootstrap modal popup for this action.</p> <p>So my codes are as follows.</p> <p><strong>Index.chtml</strong></p> <pre><code> @*Inside foreach loop*@ &lt;div class="modal hide fade" id="Delete_@index"&gt; @Html.Partial("_DeleteUser", user) &lt;/div&gt; </code></pre> <p><strong>_DeleteUser</strong></p> <pre><code>@model Classes.User &lt;div class="modal-header"&gt; &lt;button type="button" class="close" data-dismiss="modal"&gt;×&lt;/button&gt; &lt;h3&gt;İstifadəçinin məlumatları&lt;/h3&gt; &lt;/div&gt; @using (Html.BeginForm("DeleteUser", "Admin", FormMethod.Post)) { Html.HiddenFor(user =&gt; user.UserId); Html.AntiForgeryToken(); &lt;div class="modal-body"&gt; &lt;strong&gt;Bu istifadəçini silmək istədiyinizdən əminsiniz...?&lt;/strong&gt; &lt;/div&gt; &lt;div class="modal-footer"&gt; &lt;a href="#" class="btn" data-dismiss="modal"&gt;Close&lt;/a&gt; &lt;button class="btn btn-danger"&gt;&lt;i class="icon-trash icon-white"&gt;&lt;/i&gt;Save Changes&lt;/button&gt; &lt;/div&gt; } </code></pre> <p>And my HttpPost method action:</p> <pre><code> [HttpPost] public ActionResult DeleteUser(User user) { userRepository.DeleteById(user.UserId); return View("User"); } </code></pre> <p>After this scenario I get <em>{00000000-0000-0000-0000-000000000000}</em> type Guid value for User.UserId. Perhaps its has very easy solution, but I can not find an hour. Please help me.</p> <p><strong>Not:</strong> I use </p> <pre><code>1)Html.HiddenFor(user =&gt; user.UserId); 2)&lt;input type="hidden" value="@Model.UserId" id="UserId"/&gt; </code></pre> <p>but still not work.</p> <p><strong>Solution:</strong> *<em>It works when I move hidden inside model-body div, why it happend I don't know)), thanks a lot to everyone</em>*</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