views:

1651

answers:

2

Preamble:

I am using ASP.NET 3.5 and AJAXControlToolkit. I am trying to use the AutoCompleteExtender on a control I am writing which is an Address control.

The Address control has a bunch of textboxes such as Address1, Address2, City, Zip, and dropdowns such as State and Country.

Scenario:

I would like the user to start typing into Address1, and then show them other addresses that match what they have typed. If they select one, I need all the other textboxes AND dropdownlists to populate with that information. In addition I need the Primary key for that Address row they selected to show up in my code behind the scenes so that we're not duplicating data, just adding a reference to that Id.

I hope that makes sense.

So far I have created the ScriptManager, WebService and the AutoCompleteExtender.

<asp:ScriptManager ID="ScriptManager1" runat="server">
    <Services>
        <asp:ServiceReference Path="EntityService.asmx" />
    </Services>
</asp:ScriptManager>

<ajax:AutoCompleteExtender 
    runat="server" 
    ID="autoComplete1" 
    TargetControlID="txtAddress1"
    ServiceMethod="GetAddressList"
    ServicePath="EntityService.asmx"
    MinimumPrefixLength="2" 
    CompletionInterval="500"
    EnableCaching="true"
    CompletionSetCount="20" 
    CompletionListCssClass="autocomplete_completionListElement" 
    CompletionListItemCssClass="autocomplete_listItem" 
    CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
    DelimiterCharacters=";, :"
    ShowOnlyCurrentWordInCompletionListItem="true">
</ajax:AutoCompleteExtender>

Any suggestions are most appreciated on how I can go about getting this control collection populating properly.

Thanks.

A: 

Well I found the solution myself. There is a event you can bind to on click for the drop down and have the web service return an ID field as part of the event argument. Then use that to call another web service that returns a complex type with the values. Finally, use javascript to assign those values to all controls.

Easy peasy lemon squeezy!

AboutDev
A: 

Thank you for your answer AboutDev; how about illustrating your solution? That would be appreciated.

Tony Grewal
Oh man...I haven't seen this thread in a long time...sorry about that Tony. I'll put it up this weekend and post back on here.
AboutDev