ok, after long investigation , it seems like when I have a view that was created to work with the _layout.cshtml - the submit button in the form I have doesn't work (no action is returned to controller).
Only when I created a view and unchecked "Use a layout or master page" - the button has worked!
This seems extremely unclear, so - how can I have both view with the general _layout.cshtml alongside with a working form button?
below: Try to implement a form in MVC4 (+Razor)
Controller (that should get the post action):
public class GeneralController {
[HttpPost]
public ActionResult SearchResults(SearchParamsModel searchParams)
{
// doin some stuff here
return View("SearchResultsView");
}
}
View (.cshtml)
@model Models.SearchParamsModel
@using (Html.BeginForm("SearchResults", "General", FormMethod.Post))
{
<section class="form-field">
<input type="text" name="Property1" id="Property1" class="field field139 autocomplete-init-no-img" />
<label for="Property1">value1</label>
<form action="" method="post" class="clearfix">
<input
type="submit"
value="some value"
class="submit btn blue-btn special-submit" />
</form>
</section>
}
Model
public class SearchParamsModel
{
public string Property1{ get; set; }
}