Once again thank you for being so patient, Imar.
I have implemented what you have suggested (to my best knowledge):
In AttendanceController.cs, I have:
public class FindViewModel
{
public DateTime SelDate { get; set; }
public string SelTimeFrom { get; set; }
public string SelTimeTo { get; set; }
}
at the top, then further down in this:
public ActionResult Find()
{
return View();
}
It does calls the right page etc.
With the post method:
//POST: /Attendance/Post
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Find(FindViewModel find)
{
var attn = attnRepository.FindAttendance(find.SelDate);
if (attn == null)
return View("NotFound");
else
return View("CK");
NOTE: the CK view is only a temporary measure.
However it fails at var attn = attnRepository.FindAttendance(find.SelDate);
error message: "Object reference not set to an instance of an object."
it appears that "find.SelDate" is null.
I'm not sure how to set the public variable "public DateTime SelDate { get; set; }" to this search date on find.aspx
The current find.aspx is:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<GymAttendance.Co ntrollers.AttendanceFormViewModel>" %>
<asp:Content ID="Title" ContentPlaceHolderID="TitleContent" runat="server">
Find Attendance
</asp:Content>
<asp:Content ID="Find" ContentPlaceHolderID="MainContent" runat="server">
<link type="text/css" href="/Content/jquery-ui-1.8.11.custom.css" rel="stylesheet" />
<link type="text/css" href="/Content/timePicker.css" rel="stylesheet" />
<h2>Find Attendance</h2>
<%=Html.ValidationSummary("Please correct the errors and try again") %>
<%@ Import Namespace="GymAttendance.Helpers" %>
<link type="text/css" href="/Content/jquery-ui-1.8.11.custom.css" rel="stylesheet" />
<link type="text/css" href="/Content/timePicker.css" rel="stylesheet" />
<% using (Html.BeginForm()) { %>
<fieldset>
<script type="text/javascript" src="/Scripts/jquery-1.5.1.min.
js"></script>
<script type="text/javascript" src="/Scripts/jquery-ui-1.8.11.custom.min.
js"></script>
<script type="text/javascript" src="/Scripts/jquery.timePicker.
js"></script>
<script language="javascript">
$(document).ready(function () {
$('#GA_Date').datepicker({ dateFormat: '<%= Html.ConvertDateFormat() %>' });
$("#GA_Time_From").timePicker({
startTime: "07.30", // Using string. Can take string or Date object.
endTime: new Date(0, 0, 0, 20, 30, 0), // Using Date object here.
show24Hours: true,
separator: '.',
step: 15
});
$("#GA_Time_To").timePicker({
startTime: "07.30", // Using string. Can take string or Date object.
endTime: new Date(0, 0, 0, 20, 30, 0), // Using Date object here.
show24Hours: true,
separator: '.',
step: 15
});
});
</script>
<p>
<label for="GA_Date">Attendance Date:</label>
<%= Html.TextBox("GA_Date")%>
<%=Html.ValidationMessage("GA_Date", "*")%>
</p>
<p>
<label for="GA_Time_From">Time From:</label>
<%= Html.TextBox("GA_Time_From")%>
<%=Html.ValidationMessage("GA_Time_From", "*")%>
</p>
<p>
<label for="GA_Time_To">Time To:</label>
<%= Html.TextBox("GA_Time_To")%>
<%=Html.ValidationMessage("GA_Time_To", "*")%>
</p>
<p>
<input name="Find" type="submit" value="Find" />
</p>
</fieldset>
<% } %>
</asp:Content>
sorry if I sound daft but as I said earlier I still hasn't fully grasped this whole new "strategy". Thanks in advance once again.