Text field TextChange event only shooting if the user presses the space bar

I have only one text box per page. For this text box, I have the text change text box in the code behind. Since this is the only element on the page, it only starts after the user enters the input and the user presses the space bar. Is there a hack that I could use to make a text change event in the text if it lost focus, and not the user's run button?

 <asp:Textbox Id="txtInputID" runat="server" TextChanged="ReadWriteTB_TextChanged" /> private void ReadWriteTB_TextChanged(object sender, RoutedEventArgs e) { //do stuff here } 

Update. I am using jquery autoload for this text box. Not sure if this forces the user to press the spacebar.

+4
source share
1 answer

Try this :

 private void ReadWriteTB_TextChanged(object sender, RoutedEventArgs e) { txtInputID.Attributes.Add("onfocus", "javascript:this.value=this.value;") txtInputID.Focus() } <script type="text/javascript"> var MIN_TEXTLENGTH = 3; function forcePostback(ctrl) { if (ctrl != null && ctrl.value && ctrl.value.length >= MIN_TEXTLENGTH) { __doPostBack(ctrl.id, ''); } } </script> ... <asp:TextBox ID="txtInputID" OnKeyUp="forcePostback(this);" AutoPostBack="true" OnTextChanged="ReadWriteTB_TextChanged" runat="server"/> 
+3
source

All Articles