getting selected value from autoCompleteExtender

Last post 07-09-2009 6:49 AM by Vince Xu - MSFT. 10 replies.

Sort Posts:

  • getting selected value from autoCompleteExtender

    07-04-2009, 2:16 AM
    • Member
      165 point Member
    • svibuk
    • Member since 10-16-2008, 10:22 AM
    • Posts 676

     function pageLoad(){
                $find("autoCompleteBehavior1").add_itemSelected(onItemSelected); 
            }
           
            function onItemSelected(){
                //you can add some code here to send a postback.
              alert("hello")
            }

    using above oon the client side i get the messgae from alert
    but i need the select value from the autocompleteextender in the textbox
    so that i culd assign that value to a hidden field & use that in the server side query to get the corresponsing details

    i am not able to use the normal javascript code ie document.getElementById('autoCompleteExtender1').value  or even with the textbox

  • Re: getting selected value from autoCompleteExtender

    07-05-2009, 11:01 PM
    Chetan Sarode
    Software Engineer,
    Approva Systems Pvt Ltd,
    Pune, India.
  • Re: getting selected value from autoCompleteExtender

    07-05-2009, 11:36 PM
    • Star
      8,677 point Star
    • Pawan_Mishra
    • Member since 03-13-2008, 11:37 AM
    • Bangalore
    • Posts 1,266

    Hi

    Assign a client side event handler for the item selected eevent and then in that handler you can retrive the selecetd value with the following code :-

    function itemSelected(evt) {
                var index = $find("<behaviour id of the autocomplete extender>")._selectIndex;
                var dd = $find("behVendorList").get_completionList().childNodes[index]._value;

              //here you can use the above variable dd and then assign value to respective textbox
    }

    Regards
    Pawan Mishra

    Too many eyes doesn't make a good code !!!

    .Net 360°
  • Re: getting selected value from autoCompleteExtender

    07-06-2009, 1:08 AM
    • Member
      165 point Member
    • svibuk
    • Member since 10-16-2008, 10:22 AM
    • Posts 676

    i tried using aboce code

    but getting

    Microsoft JScript runtime error: 'null' is null or not an object

    the follwoing is teh javascript on client side

     

    $find(

     

    function pageLoad()

    {

    $find("autoCompleteBehavior1").add_itemSelected(onItemSelected);

    }

     

    function onItemSelected(evt) {

    var index = $find("autoCompleteBehavior1")._selectIndex;

    alert(index)

    var dd = $find("autoCompleteExtender1").get_completionList().childNodes[index]._value;

    alert(dd)

     

    i get the index butnot the value

  • Re: getting selected value from autoCompleteExtender

    07-06-2009, 3:36 AM
    • Member
      165 point Member
    • svibuk
    • Member since 10-16-2008, 10:22 AM
    • Posts 676

    the eg  links in the  page suggested by the links in this forums are not getting opened

  • Re: getting selected value from autoCompleteExtender

    07-06-2009, 11:21 PM

    Hi,

    Firstly, you can use $find('behaviorID').get_element() to get the instance of Textbox.

    In your code, please use

    var dd = $find("autoCompleteBehavior1").get_completionList().childNodes[index]._value;

    instead of

    var dd = $find("autoCompleteExtender1").get_completionList().childNodes[index]._value;

    You used incorrect behaviorID.

     


    Vince Xu
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: getting selected value from autoCompleteExtender

    07-06-2009, 11:22 PM
    • Star
      8,677 point Star
    • Pawan_Mishra
    • Member since 03-13-2008, 11:37 AM
    • Bangalore
    • Posts 1,266

    Hi

    svibuk:

    function pageLoad()

    {

    $find("autoCompleteBehavior1").add_itemSelected(onItemSelected);

    }

    Rather than setting it ion pageLoad function set this attribute directly in decleration of the control ie in markup.Where are you getting the error ie in which line ? If things are proper then alret(dd)  --> will throw an alert message showing the content of the selected value.

    Regards
    Pawan Mishra

    Too many eyes doesn't make a good code !!!

    .Net 360°
  • Re: getting selected value from autoCompleteExtender

    07-07-2009, 2:21 AM
    • Member
      165 point Member
    • svibuk
    • Member since 10-16-2008, 10:22 AM
    • Posts 676

    with the above i am getting "undefined "

    i used

    var

     

    dd =$find("autoCompleteBehavior1").get_element().value = eventArgs.get_text().split(":")[0] ;

    i get the value selected

    i even get the value on the server side

    now my prblm is with the value which i get after selection i need to get other related data of that selected value

    so i use the value frm server side in the query

    but i am not able to use it in text changed event of textbox

    & secondaly after the selection is done i need the tab to be automiticaly moved to next control

     

     

     

     

  • Re: getting selected value from autoCompleteExtender

    07-07-2009, 12:42 PM
    • Star
      8,677 point Star
    • Pawan_Mishra
    • Member since 03-13-2008, 11:37 AM
    • Bangalore
    • Posts 1,266

    Hi

    I am not getting whats not actually working for you . the code snippet which I have provided , I have been using it in many places and it has even worked for many people here in this forum. Following is how I generally use it :-

    var index = $find("<behaviour id of the autocomplete extender>")._selectIndex;
        var dd = $find("<behaviour id of the autocomplete extender>").get_completionList().childNodes[index]._value;
        $get('<id of the textbox>').value = dd.substring(0, dd.indexOf('|'));


    Please cross check whether you are getting values form the server side code properly or not . May be there you will find something which might be causing the problem.

    Regards
    Pawan Mishra

    Too many eyes doesn't make a good code !!!

    .Net 360°
  • Re: getting selected value from autoCompleteExtender

    07-08-2009, 3:13 AM
    • Member
      165 point Member
    • svibuk
    • Member since 10-16-2008, 10:22 AM
    • Posts 676

    i used the above code & getting this error

    Microsoft JScript runtime error: 'undefined' is null or not an object

    at line 

     var x=$get('tx_name').value = dd.substring(0, dd.indexOf('|'));

    in the below line

     var dd = $find("autoCompleteBehavior1").get_completionList().childNodes[index]._value;

    i get the value of dd as undefined

    this is my full code

    function pageLoad()
     {
    $find("autoCompleteBehavior1").add_itemSelected(setValue);
    }
     
    function setValue()
    {

    var index = $find("autoCompleteBehavior1")._selectIndex;
        var dd = $find("autoCompleteBehavior1").get_completionList().childNodes[index]._value;
        alert(dd)
        var x=$get('tx_name').value = dd.substring(0, dd.indexOf('|'));
    alert(x)


    }

  • Re: getting selected value from autoCompleteExtender

    07-09-2009, 6:49 AM
    Answer

     Please debug javascript in VS.

    http://www.jonathanboutelle.com/mt/archives/2006/01/howto_debug_jav.html

    this error means $get('tx_name') is a null object

     


    Vince Xu
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Page 1 of 1 (11 items)