Ask AJAX to BD when inserting data in INPUT - C #

0

I searched for information on the internet but I got a little confused, I have an input tag.

 <div class="form-group">
     <label>Stock Number</label><br />
     <input type="text" class="form-control" id="StockNumber" name="StockNumber" value="" placeholder="e.g. 1810001" required />
 </div>

I am interested in making a query to the database when entering information to the input, to know if that data already exists in the DB to send a message to the user as "Number of Stock already exists". I hope to receive your help

    
asked by ViA Alondra 11.10.2018 в 20:27
source

1 answer

0

To do that you mention you must use ajax you could do it easily by means of jquery , for this

Posting Data With jQuery AJAX In ASP.NET Razor Web Pages

In the article you will see how he uses

$.ajax({
    type: "POST",
    url: "/Receiver",
    data: car,
    datatype: "html",
    success: function (data) {
        $('#result').html(data);
    }
});

to invoke a controller action and receive the response in a json

    
answered by 11.10.2018 / 23:39
source