Below is the mark-up of my mvc-View and model.
The problem i am facing is , client validation is not firing for ko.Html.Textbox() control, but it is fine with normal Html.Textbox control.
Appreciate any solutions for this.
Dileep.
@using PerpetuumSoft.Knockout
@model MVCDemo.Models.EmployeeModel
@{
var ko = Html.CreateKnockoutContext();
}
@{
ViewBag.Title = "Home Page";
}
<script src="../../Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset>
<legend>Fields</legend>
<div class="editor-label">
@Html.LabelFor(model => model.Id)
</div>
<div class="editor-field">
@ko.Html.TextBox(model => model.Id)
@Html.ValidationMessageFor(model => model.Id)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Name)
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Address)
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.Address)
@Html.ValidationMessageFor(model => model.Address)
</div>
<p>
<input type="submit" value="Update" />
</p>
</fieldset>
}
public class EmployeeModel
{
[Required]
public int Id { get; set; }
[Required]
public string Name { get; set; }
[Required]
public string Address { get; set; }
}