It is strange to know that even after adding update panel / AsyncPostBackTrigger , TextBox ChangeEvent doesn't work properly. Some time its works and some times it not..Since its is Asynchronous call, we need to some time refresh, or wait or unpredictable , Hopes Microsoft will come up with competent one.. Below are easy way to check user name pretty good
In Page_Load-aspx.cs
this.TextBox1.Attributes.Add("onKeyUp", "fnUNameSubmit(this);");
In aspx -add script, you code:
<script language="javascript" type="text/javascript">
function fnUNameSubmit(urInput) {
var inpt= urInput.value;
if (inpt.length > 21) {
document.getElementById('<%= TextBox1.ClientID %>').style.backgroundColor = "green";
document.form1.submit(); // This is only trick we use here..
}
else {
document.getElementById('<%= TextBox1.ClientID %>').style.backgroundColor = "red";
}
}
</script>