I have a Asp.Net web form (aspx) which contains a TextBox:
<div id="field">
<asp:TextBox Id="Name" runat="server" MaxLength="50"/>
</div>
I am making a jQuery ajax call after typing characters in the TextBox which returns a list of Names from the database.
$("#field input[id*='Name']").on("input", function(e) {
$.ajax({
url: my_WebAPI_url,
type: 'Get',
dataType: 'json',
contentType: "application/json; charset=utf-8",
async: true,
success: function (result) {
console.log(result);
}
});
}
After clicking on the TextBox or typing the characters for the first time, the TextBox loses its focus. I have to click on the TextBox again, and then it works fine without losing focus.
How to make the TextBox not lose focus after clicking on it for the first time?