Jade Don

Jade Don

  • NA
  • 3
  • 514

Null Model (urgent)

Sep 15 2016 2:59 PM
Hello Guys,

I have a very simple form which looks like the following:

@model ContentAgent_Licensing_MVC.Models.Licensing.ViewModels.SearchViewModel @using (Html.BeginForm("FullSearch", "Search", FormMethod.Post)) { @Html.TextBoxFor(model => model.SearchTerms, new { @class = "control-textbox", @placeholder = "Search" }) <button type="submit"><img src="~/Content/images/search-icon.png" width="15" height="15" />button> }

The controller on the other end looks like this:

public class SearchController : Controller { [HttpPost] public ActionResult FullSearch(SearchViewModel SearchTerms) { return View("SearchResults", SearchTerms); } }

The model looks like this:

 public class SearchViewModel { public string SearchTerms { get; set; } }

The problem is when I submit the form, the SearchViewModel object is always null when I debug into the FullSearch method. Does anyone know what I'm doing wrong...?



Answers (3)