S P

S P

  • NA
  • 285
  • 212.8k

model not passing data to controller from modal popup

Jun 1 2017 2:06 PM
I have generated a partial view inside bootstrap modal popup which searches for the data from textbox on click of search Button within that modal popup.
I am using Ajax.BeginForm to send the data. But still my controller doesn't get the data i am paasing. I am using @Html.TextBoxFor in the view.(MVC)
 
Modal Popup View
@using (Html.BeginForm(FormMethod.Post))
{
<input type="button" class="aslink modal-link" data-toggle="modal" data-target="#modal2" id="btnSearchModal" value="Search company" onclick="SearchModal()">
@using (Ajax.BeginForm("_ModalSearch", "controller", new AjaxOptions() { UpdateTargetId = "Search" }))
{
<div id="Search">
@using (Html.BeginFormGroup(m => m.CompanyName))
{
@Html.TextBoxFor(m => m.CompanyName)
}
</div>
}
 
My Controller
public ActionResult _ModalSearch()
{
var model = new CompanyModel();
RefreshCompanyModel();
return PartialView("_OperatorSearch",model);
}
[HttpPost]
public ActionResult _ModalSearch(CompanyModel model)
{
var companyResults = GetCompanyResults(model);
return PartialView("_OperatorSearch", companyResults);
}
so when i am inserting any value into textbox from modal popup view, it should pass to controller via model which is not working here.