TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Abhineet Srivastava
NA
890
94.7k
Save item to Database using Knockout.js
Sep 24 2013 3:26 AM
Hi All,
I have add the record into the list using Knckout.js but now i have to save this new record to database.
Anyone have a idea?
My code is below-
-----------------
.Cshtml
------
<table data-bind="template: { name: 'emp-template', foreach: Students }" class="formatHTML5">
<thead>
<tr>
<td>First Name</td>
<td>Last Name</td>
<td>Middle Name</td>
</tr>
</thead>
<!-- <tfoot>
<tr>
</tr>
</tfoot> -->
</table>
<input data-bind="value: firstName" />
<input data-bind="value: lastName" />
<input data-bind="value: middleName" />
<button type="button" data-bind="click: addNewRow">add row</button>
<button data-bind='click: save'>Save</button>
<script type="text/html" id="emp-template">
<tr>
<td class="td-center">
<span data-bind="text: FirstName"></span>
</td>
<td class="td-center"><span data-bind="text: LastName"></span>
</td>
<td class="td-center">
<span data-bind="text: MiddleName"></span>
</td>
</tr>
</script>
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Viewmodel
-----------
var AppViewModel = function () {
var self = this;
self.firstName = ko.observable();
self.lastName = ko.observable();
self.middleName = ko.observable();
self.Students = ko.observableArray([]);
self.addNewRow = function () {
//alert("First Name Is");
//var firstName = self.firstName.trim();
//var lastName = self.lastName.trim();
//var middleName = self.MiddleName.trim();
self.Students.push({ FirstName: self.firstName(), LastName: self.lastName(), MiddleName: self.middleName() });
};
}
$(document).ready(function () {
var viewModel = new AppViewModel();
$.getJSON('/ajaxCall/getEmpAjax/', function (data) {
viewModel.Students(data);
ko.applyBindings(viewModel);
});
});
Reply
Answers (
1
)
How to set tabindex in RadioButtonList control in asp.net?
Printing barcode and label without prn files