Wednesday, August 24, 2016

Telerik and Webforms: Trimming Paste on a RadComboBox

I had an issue with being able to trim incoming text into a radcombobox.  The code below is really simple but it took me a bit to figure out.  I'm stuck not using the latest release of Telerik's ASP.Net webform controls so maybe there is a different way to do this with later versions, but this worked for me.


I'm plugging into the RadComboBox's OnClientItemsRequesting by setting it to "MyItemsRequesting"

  function MyItemsRequesting(s, e) {  
     var txt = e.get_text();  
     if (txt != txt.trim()) {  
      e.set_cancel(true);  
      var d = document.getElementById("mymasternamepageifany" + "_mydropdownid_Input");  
      if (d != null) d.value = txt.trim();  
      s.requestItems(txt.trim(), false);  
     }  
   /* more code */  
  }  



No comments: