Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdating div content after submiting ajax form in asp.net MVC3
    primarykey
    data
    text
    <pre><code>&lt;div id="myDiv"&gt; &lt;ul class="purpose"&gt; @{ var purpose = CommonMethod.getPurpose(""); for(int i=0;i&lt;10 &amp;&amp; i&lt;purpose.Count();i++) { &lt;li&gt;&lt;a href="#" &gt;@purpose[i].Text&lt;/a&gt;&lt;/li&gt; } } &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>on selecting the above single purpose from list it will show below ajax form for updation</p> <pre><code>@using (Ajax.BeginForm("UpdatePurpose", "Admin", new AjaxOptions { UpdateTargetId = "updateDiv" })) { &lt;div class="profile"&gt; @Html.Hidden("PurposeID") &lt;table&gt; &lt;tr&gt; &lt;td&gt;Purpose&lt;/td&gt; &lt;td&gt;:&lt;/td&gt; &lt;td&gt; width="30%"&gt;@Html.TextBox("Description")&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Admin Password&lt;/td&gt; &lt;td&gt;:&lt;/td&gt; &lt;td&gt;@Html.Password("Passwd1")&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;input type="submit" value="submit" /&gt; &lt;/div&gt; } </code></pre> <p>After Subting below action is called</p> <pre><code>[HttpPost] public ActionResult UpdatePurpose(string PurposeID,string Description, string Passwd1) { if (Request.IsAjaxRequest()) { if (!Membership.ValidateUser(User.Identity.Name, Passwd1)) { ModelState.AddModelError("", "Invalid Admin Password"); } if (ModelState.IsValid) { var id = Convert.ToByte(PurposeID); var pur = db.Purposes.Where(p =&gt; p.PurposeID == id).SingleOrDefault(); pur.Description = Description; db.SaveChanges(); ViewBag.Result = "Data Updated Successfully."; return View(); } } return View(); } </code></pre> <p>On submitting above ajax form Updatepurpose I want to show validation message errors if admin password is invalid and also I want to load myDiv content if modelstate is valid and give successful updation message to user</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.
    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