Question

I have an AutoCompleteExtender that calls a web service. The AutoCompleteExtender works well and the Target TextBox (tb_provider1) has autocomplete functionality from the GetProviders function. I would like to call a javascript function upon selection of the autocomplete text of the TextBox (tb_provider1). I have used the OnClientItemSelected and the call is done correctly in IE9. Here is ASPX code:

<asp:AutoCompleteExtender ID="AutoComplete1" 
runat="server" ServiceMethod="GetProviders" 
ServicePath="AutoCompleteWebService.asmx" OnClientItemSelected="ProviderSelectedFunc"
TargetControlID="tb_provider1" CompletionSetCount="20" 
CompletionInterval="250" CompletionListCssClass="CompletionListCssClass" 
CompletionListItemCssClass="CompletionListItemCssClass" 
CompletionListHighlightedItemCssClass="CompletionListHighlightedItemCssClass">

And here is the javascript

function ProviderSelectedFunc(sender, args) {
        //here I know I am sending in tb_enrollingProvider1
        var temp = sender._id.toString();
        if (temp.substr(-14,13))
            alert("Testing");
    }

In IE9, the alert fires. In IE7/IE8 nothing happens. Any help?

Was it helpful?

Solution

I was unaware that you could press F12 in IE9 and change the browser mode. After doing this, I used breakpoints and realized it wasn't not getting to the javascript but that a javascript substr method was returning different results in IE8 and IE9. So the OnClientItemSelected was working and it was failing in my method call. The use of F12 in IE to debug was big here as was the use of the "substring" (instead of "substr").

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top