Question

I am developing a web application without any models. I just do not need them for what I am trying to do. I want to take some input from the view and to pass it on the controller. So far so good. The problem is that on the view I get some unwanted text: "System.Web.Mvc.Html.MvcForm"; it comes from the follwoing line: @Html.BeginForm("GetInfo", "Test", FormMethod.Post, new { id = "TestForm" } )

More precisely, my code is this: --the view

    @Html.BeginForm("GetInfo", "Test", FormMethod.Post, new { id = "TestForm" } )
    <br/>
    <legend>Report</legend>
    <br />
    <div class="editor-label">
        <label>Date From</label>
    </div>
    <div class="editor-field">
        <input name="dateFrom" type="date" required />
    </div>
    <br />

<input type="submit" class="btn btn-primary" />

and the method from the controller is :

 public ActionResult GetInfo(DateTime dateFrom)
        {
//some code
            return RedirectToAction("Index");
        }

Any ideas? Thank you in advance! :)

Was it helpful?

Solution

Try

@using (Html.BeginForm(.....))
{
  // Html here
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top