I have a from and to date search box on my view.
This POSTs to my controller, which then searches for available rooms between the dates selected. The results are then listed in the view again.
I'm used to WebForms, where you can PostBack, and grab any control data - however in MVC you can't do this.
When the results are displayed, how can I then POST back to a controller, both the RoomId that has been selected:
@Html.ActionLink("Book Room","Book", new { id=item.RoomId })
...and the tbFrom and tbTo dates from the TextBoxes?
My view is below.
Thanks for any assistance,
Mark
@model IEnumerable<ttp.Models.Room>
@{
ViewBag.Title = "Avail";
}
<h2>Avail</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
@using (Html.BeginForm())
{
<p>
Availability between @Html.TextBox( "dteFrom" , String.Format( "{0:dd/MM/yyyy}", DateTime.Now) , new { @class = "datepicker span2" } )
and @Html.TextBox( "dteTo" , String.Format( "{0:dd/MM/yyyy}", DateTime.Now) , new { @class = "datepicker span2" } )
<input type="submit" value="Search" /></p>
}
<table class="table table-striped table-bordered table-condensed" style="width:90%" id="indexTable" >
<tr>
<th>
@Html.DisplayNameFor(model => model.RoomName)
</th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.RoomName)
</td>
...
...
<td>
@Html.ActionLink("Book Room","Book", new { id=item.RoomId })
</td>
</tr>
}
</table>