I have three text boxes, first name txtFirstName, last name txtLastName and AD User ID txtADUserID. Whenever first name or last name is changed, I am assigning AD user id value in Jquery code. I see in browser that ADUserID textbox value is changed.
PROBLEM: I need to check if user id already exist in txtADUserID's ontextchanged server side event. OnTextChanged event is NOT fired at all and postback is also not raised.
ASP.net code
<asp:TextBox ID="txtADUserID" runat="server" MaxLength="255" ClientIDMode="Static" OnTextChanged="txtADUserID_TextChanged" AutoPostBack="true"></asp:TextBox>
Jquery code:
$(document).ready(function () {
$("#txtFirstName").on('change', function () {
$('#txtADUserID').val($('#txtFirstName').val().charAt(0) + $('#txtLastName').val());
});
$("#txtLastName").on('change', function () {
$('#txtADUserID').val($('#txtFirstName').val().charAt(0) + $('#txtLastName').val());
});
});
Code behind code:
protected void txtADUserID_TextChanged(object sender, EventArgs e)
{
// Raise an error if user already exist
}