get *only* the text that you typed (and that is allowed)

3 posts, 1 answers
  1. David
    David avatar
    38 posts
    Member since:
    May 2013

    Posted 06 Nov 2013 Link to this post

    i am trying to get the text that i have typed into my radcombobox.

    The combobox is defined as :

    cmb = New RadComboBox
          cmb.ID = "cmbSearch"
          cmb.ShowDropDownOnTextboxClick = False
          cmb.MarkFirstMatch = True
          cmb.DataTextField = "TextField"
          cmb.DataValueField = "ValueField"
          cmb.ShowToggleImage = False
          ' cmb.AutoPostBack = True
          cmb.Attributes("onkeyup") = "handleKeyPress();"
          If Not Page.IsPostBack Then
              cmb.DataSource = _recipe.getAllStockItems(_security.UserID, _security.DivisionId)
              ViewState("cmbDataSource") = cmb.DataSource
          End If

    now, every time i type something into the box, the 'handleKeyPress' javascript function runs - as you can see in the above code.

    this javascript function is defined as:

    function handleKeyPress()
        var combo = $find('<%=cmb.ClientID%>');
        //  alrt('error');
        document.getElementById('<%=hidAutoComplete.ClientID%>').value = combo._filterText;
     //   alrt('error');
        <%=Page.ClientScript.GetPostBackEventReference(hidAutoComplete, "Change")%>

    this is almost ok.
    The point that is confusing me is that the 'combo._filterText' gives me my text that i have typed, and this would look like it works.
    the radcombobox has an item 'david'. i type in 'da' and the radcomobobx autocompletes it to 'david' but combo._filtertext gives me 'da'.
    this is correct and how i would expect it to work.

    now, if i typed 'daa' (which doesn't exist in the combobox), the combobox stops me from adding this extra 'a' and will autocomplete it to 'david'.
    this is also correct. unfortunately, and this is the problem, 'combo._filtertext' shows 'daa'.

    is it possible to get just 'da'. that is, only the text i have entered, and that i am allowed to enter?
  2. Answer
    Nencho avatar
    1812 posts

    Posted 11 Nov 2013 Link to this post

    Hello David,

    I am afraid, that the desired typed text could not be access using any property or method of the RadComboBox, since the Text of the RadComboBox is automatically set to the first found match. However, you could compare both string ._filterText and .get_text(), in order to capture the matching substrings.

    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. David
    David avatar
    38 posts
    Member since:
    May 2013

    Posted 12 Nov 2013 Link to this post

    that you for your advice.
    i have added the following, to give me what I need:

    var filtText =  String(combo._filterText);
    var fullText = String(combo.get_text());
    var actualFilterText = '';
    for (var i = 0,len = filtText.length; i < len; i++){
        if (filtText[i].toUpperCase() == fullText[i].toUpperCase()){
            actualFilterText += filtText[i];
Back to Top