O'Reilly logo

Getting Started with Knockout.js for .NET Developers by Andrey Akinshin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sending parameters to the server

One of the common tasks in the development of responsive applications is the AJAX execution of a controller method. Sometimes, we need to execute the method with some parameters (or method arguments). Let's consider a simplified version of the library example; we will keep only the number of books. In the following example, the business model needs three methods: the addition of one book, the addition of two books, and the addition of three books. Of course, we can implement three different methods for these tasks. However, a single method with an argument is a more flexible approach.

The Model will be as follows:

public class LibraryModel { public int AmountOfBooks { get; set; } public void AddBooks(int count) { ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required