How to dynamically track the number of button clicks on ASP.NET.

I want to create a form where people can register for the course. The number of people for the course is limited. I want to create a page where the user can see how many places are still available, and the number is dynamically updated, so if another user subscribes to the course, the other sees the changes. When the number of available seats reaches 0, the registration button should be disabled. Such a task should be easily implemented, but I am afraid that this is not so. I suppose some Ajax will be involved, but how to handle the server side counts? WebServices? I had a problem in developing the logic of all of this.

+1
source share
2 answers

The technology / technology you are looking for is called Server Push.

The main idea: the client should respond to some events occurring on the server.

Possible solutions:

  • Polling some server actions through AJAX in a timely manner;
  • Saving a long-term AJAX request on the server side until a timeout or event occurs, and then process the result on the client (determine if this was a server action or just a timeout), if necessary, reconnect to the client.

and several other solutions, which are mainly variations of the two above. Also, the solution will depend heavily on the server-side technology you use.

Google has a short but very informative article on what this technique is and how it can be implemented here . He is an (almost) technological agnostic, so he should help you understand the concepts and possible solutions.

+2
source

I would use a database on the server. In the table "courses" there is a related table containing "orders". Add them to your SQL query.

0
source

Source: https://habr.com/ru/post/1398561/


All Articles