Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

AutoCompleteExtender - Clear textBox when result not found.

$
0
0

Hi,I have an AutoCompleteExtender, a textbox and a hiddenField on my form. What I would like to do is clear the textbox and hidden field's value if user does not select the item from the autocomplete list (or if data typed on textbox does not exists in DB). Below is the code I have got so far...

<asp:TextBoxID="txtAutoCopleteProduct"runat="server"Width="80%"></asp:TextBox>                    

<cc1:AutoCompleteExtenderID="AutoCompleteExtender1"runat="server"TargetControlID="txtAutoCopleteProduct" ServiceMethod="GetProducts"ServicePath="SFAWebService.asmx"MinimumPrefixLength="4"FirstRowSelected="true"CompletionInterval="10"CompletionSetCount="50"BehaviorID="AutoCompleteEx"    
OnClientItemSelected="OnProductSelected"DelimiterCharacters=""ShowOnlyCurrentWordInCompletionListItem="true"></cc1:AutoCompleteExtender>

  <asp:HiddenFieldID="hdnProductID"runat="server"/>

 

FunctionOnProductSelected(source, eventArgs) {          

var hdnValueID = "<%= hdnProductID.ClientID %>";

document.getElementById(hdnValueID).value - eventArgs.get_value();

_doPostBack(hdnValueID,"");

}

I think I need to clear the textbox on OnTextChanged event of textbox. Is there a way I can use any events of AutoCompleteExtender without making a trip back to database?

 

Thank you in advance for your responses.

           


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>