Edit.aspx:
<th>Calendar<input id="datepicker" name="datepicker" type="text" class="input-box"/></th>
Controller action:
// POST: /Studenti/Edit/5
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Edit(int[] rb, int id, string datepicker)
{
List<nastava_prisustvo> nastava = new List<nastava_prisustvo>();
if (String.IsNullOrEmpty(datepicker))
ModelState.AddModelError("datepicker", "First name is required");
try
{
if (ModelState.IsValid)
{
string poruka = "";
for (int i = 1; i <= rb.Length; i++)
{
string name = "chk" + i;
string selID = Request.Form[name];
if (selID == "on")
{
nastava.Add(new nastava_prisustvo
{
br_indexa = int.Parse(Request.Form["id_stud" + i]),
id_predmet = id,
datum = System.DateTime.Parse(Request.Form["datepicker"])
});
}
}
return View("show", nastava);
}
}
catch(Exception ex){
ModelState.AddModelError("*", "An unexpected error occurred.");
}
return View("show", nastava);
}
}
How to validate datepicker fiel? How stop posting data if date is not selected and show appropriate message. I use ASP>NET MVC 1 and read this http://www.superexpert.com/Blog/archive/2008/09/09/asp-net-mvc-tip-42-use-the-validation-application-block.aspx but did not solve my problem