开发者

ASP.Net MVC Ajax RenderPartial not rendering correctly

开发者 https://www.devze.com 2022-12-17 02:08 出处:网络
I have an AJAX form which returns a partial view, but instead of the target div getting updated, when I submit, only the partial view is shown.As far as I can tell, I have everything set up the way it

I have an AJAX form which returns a partial view, but instead of the target div getting updated, when I submit, only the partial view is shown. As far as I can tell, I have everything set up the way it's supposed to be, what's going wrong?

    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewU开发者_Go百科serControl<ApplianceSurvey.Models.Item>" %>
<% using (Ajax.BeginForm("AddSurveysAJAX",
     new AjaxOptions { UpdateTargetId = "SurveyListContent", InsertionMode = InsertionMode.Replace }))
   { %>
      <%= Html.Hidden("itemID", Model == null ? ViewData["itemID"] : Model.ItemID) %>
      <%= Html.ListBox("SurveysLst", ViewData["Surveys"] as MultiSelectList)%>

      <input type="submit" value=">>>" />

      <%= Html.ListBox("SelSurveysLst", ViewData["ItemSurveys"] as MultiSelectList)%>


<% } %>

and in the controller:

[AcceptVerbs(HttpVerbs.Post)]
    public PartialViewResult AddSurveysAJAX(FormCollection formValues)
    {
      //do stuff          
      return PartialView("ItemSurveys");
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消