Ajax.BeginForm returning PartialView as View

2

Good Night!
I'm working on a Bed Management project. In a given View, I am displaying the Registered Nurses, and for filtering purposes , a field where you can search for the name of the Department to which the ward ( s) belongs.
As pictured below:


Forthat,I'musingtheajaxHelperAjax.BeginFormtoreturnaPartialViewandpopulatethetable.TheproblemisthatI'mgettingaseparateviewwithonlythedata.Ialreadyresearchedhereonthesite,somepeoplehadthesameproblemandincludedUnobtrusivein_Layout,butIalreadydidthat.Ihavecheckedeverythingseveraltimes,andIcannotidentifywhatishappening.

  • Web.configisalreadysettoUnobtrusiveforTrue
  • I'vealreadyincludedthepackagevalidate.Unobtrusive
  • AsDefault_LayoutdoesnotloadUnobtrusive,Ialreadydidthisfix.
  • MycontrollerhasActionPartialViewResult

InNursingControllerIhave:

[HttpPost][ValidateAntiForgeryToken]publicPartialViewResultIndexDep(stringpesquisa){returnPartialView((_enfermariaAppService.ObterPeloNomeDoDepartamento(pesquisa)));}

IntheIndex(theimageabove)Ihavethefollowingcode:

//AjaxOptions@{varajaxOpts=newAjaxOptions{UpdateTargetId="tbBody",
        HttpMethod = "Post",    
    };
}
//Formulário 
@using (Ajax.BeginForm("IndexDep", ajaxOpts))
{
   @Html.AntiForgeryToken()
   <div class="form-inline">
       @Html.TextBox("pesquisa","", new { @class = "form-control", @placeholder="Pesquise pela sigla do departamento" })
       <input type="submit" value="Pesquisar" class="btn btn-info" />
   </div>      
}
//Tabela onde deveria ser repassado a partialView
<table class="table table-bordered">
    <thead>
        //Cabeçalhos...
    </thead>
    <tbody id="tbBody">
        //Linhas...
    </tbody>

From now on, I thank you immensely for all of you who can collaborate. Thanks.

    
asked by anonymous 02.06.2015 / 00:09

1 answer

2

Okay, according to your comment that clarified my doubt, you also need to add jquery.unobtrusive-ajax .

Just look for Microsoft.jQuery.Unobstusive.Ajax or Package Manager Console and add it to the project.

Then add to your View that contains the helper Ajax.BeginForm as you did with jQuery Validate Unobtrusive .     

02.06.2015 / 14:37