How do you submit a dropdownlist in asp.net mvc from an Ajax form

前端 未结 7 1790
自闭症患者
自闭症患者 2020-12-25 13:12

How do you submit from a dropdownlist \"onchange\" event from inside of an ajax form?

According to the following question: How do you submit a dropdownlist in asp.ne

7条回答
  •  爱一瞬间的悲伤
    2020-12-25 13:36

    Can we see your Controller code? You can use Request.IsMvcAjaxRequest() in your controller to return only a portion of data if it is an Ajax Request instead of an entire View. In your View move your form to a PartialView and call

    Html.RenderPartial("viewname");

    In your Controller:

    if (Request.IsMvcAjaxRequest())
    {
    return PartialView("viewname");
    }
    else
    { //Non Ajax code here. }

提交回复
热议问题