Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Employee
- {
- [Key]
- public long AutoId { get; set; }
- [Required]
- Display(Name = "Employee ID")]
- public string EmployeeId { get; set; }
- [Required]
- [DataType(DataType.Password)]
- [Display(Name = "Password")]
- public string EmployeePassword { get; set; }
- public string FirstName { get; set; }
- public string LastName { get; set; }
- public string MiddleName { get; set; }
- }
- $(function () {
- ko.applyBindings(LoginVm);
- });
- //VIEW MODEL. MODEL IS BELOW THIS
- var LoginVm = {
- thisEmp: ko.observable(EmpObject),
- LogUser: function () {
- var self = this;
- //trying to check if thisEmp properties has values by alerting
- alert("ID: " + thisEmp.EmployeeId() + " Password: " + thisEmp.EmployeePassword());
- $.ajax({
- url: '/Employee/AuthenticateUser',
- type: 'POST',
- dataType: 'json',
- data: ko.toJSON(thisEmp),
- contentType: 'application/json',
- success: function (errorMsg) {
- if (errorMsg === '') {
- }
- }
- });
- }
- };
- //MODEL
- var EmpObject = {
- EmployeeId: ko.observable(''),
- EmployeePassword: ko.observable('')
- }
- @using (Html.BeginForm()) {
- @Html.ValidationSummary(true)
- <fieldset>
- <legend>Employee</legend>
- <div class="editor-label">
- @Html.LabelFor(model => model.EmployeeId)
- </div>
- <div class="editor-field">
- @Html.TextBoxFor(model => model.EmployeeId, new { data_bind="value: thisEmp.EmployeeId()"})
- @Html.ValidationMessageFor(model => model.EmployeeId)
- </div>
- <div class="editor-label">
- @Html.LabelFor(model => model.EmployeePassword)
- </div>
- <div class="editor-field">
- @Html.PasswordFor(model => model.EmployeePassword, new { data_bind="value: thisEmp.EmployeePassword()"})
- @Html.ValidationMessageFor(model => model.EmployeePassword)
- </div>B
- <p>
- @*<input type="submit" value="Create"/>*@
- <input type="button" value="Login" data-bind="click: LogUser"/>
- </p>
- </fieldset>
- }
- Uncaught TypeError: Unable to process binding "value: function (){return thisEmp().EmployeeId }"
- Message: Cannot read property 'EmployeeId' of undefined
- at value (eval at createBindingsStringEvaluator
Add Comment
Please, Sign In to add comment