Connecting Tech Pros Worldwide Help | Site Map

AutoCompleteExtender - How to perform an event on value select

Member
 
Join Date: Jun 2009
Location: Bangalore
Posts: 41
#1: Sep 4 '09
Hi Team

I tried a lot to get the answer but did not get it on web.

I am using an AutoCompleteExtender and getting the names fron database thru a webservice.

Now I want to select name option from the Extender and want to get the empID of that employee so that I can pass it to an ASP page as query string.

But not sure how to perform an event on selected value.

Please help!

Thanks,
Manik
best answer - posted by Frinavale
Well you could fire the event when the user clicks the Enter key :)
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,066
#2: Sep 4 '09

re: AutoCompleteExtender - How to perform an event on value select


You can't really do it on the "select" event.
Have you considered posting back to the server during the onblur JavaScript event?
Member
 
Join Date: Jun 2009
Location: Bangalore
Posts: 41
#3: Sep 7 '09

re: AutoCompleteExtender - How to perform an event on value select


Thanks Frinavale for responding.

Actully, I am trying to do the same as GOOGLE suggestion dropdown has. On selction of suggestion item, it should take you the particular suggestion link.

Can we do it thru onblur javacript?
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,066
#4: Sep 7 '09

re: AutoCompleteExtender - How to perform an event on value select


Well you could fire the event when the user clicks the Enter key :)
Member
 
Join Date: Jun 2009
Location: Bangalore
Posts: 41
#5: Sep 11 '09

re: AutoCompleteExtender - How to perform an event on value select


Thanks issue resolved!!
Newbie
 
Join Date: Nov 2009
Posts: 1
#6: 2 Weeks Ago

re: AutoCompleteExtender - How to perform an event on value select


Hello

I'm trying to achieve the exact same thing, without any success. :(

Could you tell us how you did it ? (a code sample would be perfect ;) )

Thank you !
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,066
#7: 2 Weeks Ago

re: AutoCompleteExtender - How to perform an event on value select


What have you tried?
Member
 
Join Date: Jun 2009
Location: Bangalore
Posts: 41
#8: 2 Weeks Ago

re: AutoCompleteExtender - How to perform an event on value select


you can go thru this http://www.c-sharpcorner.com/UploadF...eExtender.aspx with an update panel and thn later on you can follow below two steps.

1. have below jscript in your head of the page where your AutoCompleteExtender is placed
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.         function Test(sender,e)
  3.         {
  4.  
  5.         __doPostBack("UpdatePanel1",sender._element.value) ;
  6.  
  7.         }
  8.  
  9.         </script>

2. Have something like this in your page_load

Expand|Select|Wrap|Line Numbers
  1.  private void Page_Load(object sender, System.EventArgs e)
  2. {
  3.         Page.RegisterHiddenField("__EVENTTARGET", "btn");
  4.         TextBox1.Attributes.Add("onkeypress", "return controlEnter('" + btn.ClientID + "', event)"); 
  5.         //btn.Focus();
  6.         TextBox1.Attributes.Add("autocomplete", "off");
  7.  
  8.         if (IsPostBack)
  9.         {
  10.  
  11.            if (Request.Form["__EVENTTARGET"] != null &&
  12.            Request.Form["__EVENTTARGET"] == "UpdatePanel1" &&
  13.             Request.Form["__EVENTARGUMENT"] != null)
  14.             {
  15.                abc = Request.Form["__EVENTARGUMENT"];
  16.         //this is the selected value - what you have selected in dropdown of AutocompleteExtender and later on you can run the query into database based on this value..in my case it was name and i fatched id thru name    
  17.            }


I hope it will help you..
Reply

Tags
autocompleteextender