<script type="text/javascript" src="~/Scripts/App/AdminScript.js"></script> <script type="text/javascript" src="~/Scripts/App/fileBindler.js"></script> <script type="text/javascript"> $(document).ready(function () { window.ko.applyBindings(new CategoryViewModel()); }); </script> <div id="divEditCategory"> <h2>Edit Category</h2> <div data-bind="with:currentCategory"> <p>Category Name: <input type="text" placeholder="Category Name" class="form-control" data-bind="value:CategoryName" /></p> <p>Category Name: <input type="file" id="imgPath" accept="image/*" data-bind="value: ImagePath" /></p> <p><input type="checkbox" data-bind="value:IsActive" />Is Active</p> </div> <p><input type="button" id="sendCategory" class="btn btn-success" value="Save" data-bind="click: saveCategory" /></p> </div>
function Category(categoryName, imagePath, isActive) { var fd = new FormData(); var self = this; self.CategoryName = ko.observable(categoryName); self.IsActive = ko.observable(isActive), self.ImagePath, = ko.observable(imagePath), } function CategoryViewModel() { var self = this; self.currentCategory = ko.observable(new Category("","", true)); self.saveCategory = function () { debugger; var json1 = ko.toJSON(self.currentCategory); debugger; $.ajax({ url: '/Admin/EditCategory', type: 'POST', dataType: 'json', data: json1, contentType: 'application/json; charset=utf-8', success: function (data) { var message = data.Message; } }); } }
<pre>...</pre>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)