locked
can't find the property about onclientitemselected on AutoCompleteExtender RRS feed

  • Question

  • User-1497429768 posted

    Hi,

       why can't I find the property about onclientitemselected on AutoCompleteExtender.This is my code:

    <ajaxtoolkit:AutoCompleteExtender ID="AutoCompleteExtender1"
     MinimumPrefixLength="1" TargetControlID="txtAutoCompleteforCompany"
     CompletionSetCount="10"CompletionInterval="100"
     ServiceMethod="GetCompanyList"
     ServicePath="../UiHelper/CompanyServiceForAutoSuggest.asmx"
     runat="server" OnClientItemSelected="setCompanyMasterID"
     CompletionListElementID="listPlacement">

    I can't use the property about OnClientItemSelected. Have any idea?

    And how can I find the ID of AutoCompleteExtender1 inside in formview1 and masterpage? like this-

    function txtAutoCompleteforCompany_onkeydown() {
                var txtAutoCompleteforCompany= document.getElementById('<%=FormView1.FindControl("txtAutoCompleteforCompany").ClientID%>');
                var AutoCompleteExtender1ClientId = '<%=FormView1.FindControl("AutoCompleteExtender1").ClientID %>';
                var AutoCompleteExtender1 = $find(AutoCompleteExtender1ClientId);
                if (AutoCompleteExtender1!= null)
                    AutoCompleteExtender1.set_contextKey(txtAutoCompleteforCompany.value);
                        }

    Thanks.

    Saturday, September 26, 2015 11:47 PM

Answers

All replies

  • User61956409 posted

    Hi jeff.wenchai,

    Firstly, AutoCompleteExtender supports OnClientItemSelected property. It will be called when the user makes a selection.

    http://www.codeproject.com/Articles/71338/Using-the-AutoComplete-Extender-to-Automatically-P

    Secondly, you could check the html structure of your FormView1 and find ClientID  of AutoCompleteExtender1 from FormView’s cell using jQuery instead of using FindControl method.

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, September 27, 2015 10:29 PM
  • User-1497429768 posted

    Hi Fei Han,      

         Thank you for your prompt reply. When I add the property of onclientitemselected into ajaxToolkit:AutoCompleteExtender,and run the system,it will show that
    The page renders a parser error stating : Parser Error Message: Type 'AjaxControlToolkit.AutoCompleteExtender' does not have a public property named 'OnClientItemSelected'.
    The version of AjaxControlToolKit i have is 1.0.61025.0.

         If fact,I hope to get the ID of AutoCompleteExtender by OnClientItemSelected.So you say check the html structure of your FormView1 and find ClientID  of AutoCompleteExtender1 from FormView’s cell using jQuery .Sorry,I can't understand. Can you explain in detail how to get ID of AutoCompleteExtender?

        I view the source code in html,and find the  ID of AutoCompleteExtender.The following is the code-

    function tbTextbox_onkeydown() {
    var lbVdate = document.getElementById('_ctl0_ContentPlaceHolder1_FormView1_tbVDate');
    var AC2 = $find(AC2Behavior);
    AC2.set_contextKey(lbVdate.value);
    }

    When the AutoCompleteExtender just in formview,It work find.But if the AutoCompleteExtender is inside in formview and masterpage,It can't work.

    I hope any suggestion. Thanks a lot.

    Sunday, September 27, 2015 11:47 PM
  • User-1497429768 posted

    To Fei Han,

      Finally,I modify the code -

    function tbTextbox_onkeydown() {
    var lbVdate = document.getElementById('_ctl0_ContentPlaceHolder1_FormView1_tbVDate');
    $find('AC2Behavior').set_contextKey(lbVdate.value);
    }

    And it work,Thanks.

    Monday, September 28, 2015 4:44 AM