Ajax.BeginForm refreshing the whole page in MVC

后端 未结 2 439
余生分开走
余生分开走 2021-01-24 17:26

I\'ve been trying to add some Ajax functionality to my mvc site, however, I run into a problem regarding page refreshing. I\'ve created an rss view on my homepage sidebar, which

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-24 18:07

    Did you try initializing the InsertionMode member into the AjaxOptions object initializer?

    You also have to include 'jquery.unobtrusive-ajax.js' to make Ajax.BeginForm to work as answered here

     @using (Ajax.BeginForm("Index", "Home", null,
        new AjaxOptions
        {
            HttpMethod = "post",
            InsertionMode = InsertionMode.Replace,            
            UpdateTargetId = "feedList"
        });
    {
        @Html.DropDownListFor(x => x.SelectedFeedOption, Model.FeedOptions)
         
    }
    

提交回复
热议问题