I have a view that has to pass a start date, an end date, and a guestnumbers int to a controller.
The view is this with formatting stripped out ....
@using (Html.BeginForm("Index", "BookingCalculation", new { BookingFrom = "BookingFrom", BookingTo = "BookingTo", GuestNumbers = "GuestNumbers" },FormMethod.Post))
{
@Html.JQueryUI().Datepicker("BookingFrom").DefaultDate(DateTime.Today).MinDate(DateTime.Today)
@Html.JQueryUI().Datepicker("BookingTo").DefaultDate(DateTime.Today).NumberOfMonths(2)
@Html.TextArea("GuestNumbers","2")
<input type ="submit" value ="submit" />
}
The Controller is this ....
public ActionResult Index(string BookingFrom, string BookingTo, int? GuestNumbers) {
I passed the datetime through as a string so it can take null values.
How do I wire up the parameters to pass data through? It always passes null no matter what I set. Yet the two are connected as a click on the Index in (Html.BeginForm("Index" takes me to the method.
It doesn't throw any errors just doesn't pass data across.
As you can tell I am a noob at ASP.net. :-)