When I am making an ajax call the controller is redirecting and not updating my tags my code looks like as follows.
This is in the _layout.cshtml
<code>
<script src="@Url.Content("~/Scripts/jquery-1.4.1.min.js")" type="text/javascript">
</script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/MicrosoftAjax.js")" type="text/javascript">
</script>
<script src="@Url.Content("~/Scripts/MicrosoftMvcAjax.js")" type="text/javascript">
</script>
</code>
And This is what the web config looks like, I have also tried turning off unobtrusive javascript off with no luck.
<code>
<appSettings>
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
</code>
My controller method looks like this
<code>
[HttpPost]
public ActionResult Create(lesson lesson)
{
if (ModelState.IsValid)
{
//Save Album
lesson.dateCreated = DateTime.Now;
lesson.dateSubmitted = DateTime.Now;
lesson.statusID = SUBMITTED;
lesson.submittedByUserID = getAppUserID();
lesson.prjLessonID = createLessonPrjID(lesson.projectID);
storeDB.lessons.InsertOnSubmit(lesson);
storeDB.SubmitChanges();
return RedirectToAction("Index");
}
// Invalid – redisplay with errors
else
return View(lesson);
}
&l开发者_开发问答t;/code>
Any ideas? Thanks in advance.
<code>
@if (item.statusID != null)
{
<td id ="approvedmsg">@item.getLessonStatus(item.statusID.Value)</td>
}
else
{
<td> </td>
}
@if (item.statusID != 3)
{
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.lessonID }) |
@Ajax.ActionLink("Delete", "Delete", new { id = item.lessonID }, new AjaxOptions { UpdateTargetId = "approvedmsg"})
</td>
}
</code>
Try deleting MicrosoftAjax.js
and MicrosoftMvcAjax.js
and only use
<script src="<%=Url.Content("~/Scripts/jquery-1.4.1.min.js")%>" type="text/javascript"></script>
<script src="<%=Url.Content("~/Scripts/jquery.validate.min.js")%>" type="text/javascript"></script>
<script src="<%=Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")%>" type="text/javascript"></script>
<script src="<%=Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")%>" type="text/javascript"></script>
A good post about it here http://yobriefcase.posterous.com/unobtrusive-javascript-in-mvc3
精彩评论