The best way to achieve this in ASP.NET Core is to use AJAX calls to the API endpoint and update the button text on the client-side once the API call is successful.
Below are the high-level steps:
- Create an API endpoint that accepts the user’s invitation details and updates the user’s record in the database to indicate that they have been invited.
- On the client-side, add an event listener to the button click event that sends an AJAX call to the API endpoint.
- In the AJAX success callback, update the button text to “Invited”.
Here’s an example code snippet to give you an idea of how this can be implemented using jQuery:
Note that this is just a high-level example, and you’ll need to modify the code to fit your specific use case. Additionally, you’ll need to handle errors and edge cases, such as if the API call fails or if the user clicks the button multiple times.