views:

593

answers:

1

I have a web page where the user will enter their address. They will select their country and region in cascading drop down lists. I would like to provide an auto completing textbox for their city, but I want to be context sensitive to the country and region selections. I would have just used another cascading drop down list, however the number of cities exceeds the maximum number of list items.

Any suggestions or cool code spinets out there that may help me out?

A: 

I just found the following blog post that looks at least close to what you want.

They manage it using the following javascript functions:

    function initCascadingAutoComplete() {
        var moviesAutoComplete = $find('autoCompleteBehavior1');
        var actorsAutoComplete = $find('autoCompleteBehavior2');
        actorsAutoComplete.set_contextKey(moviesAutoComplete.get_element().value);
        moviesAutoComplete.add_itemSelected(cascade);

        // setup initial state of second flyout
        if (moviesAutoComplete.get_element().value) {
            actorsAutoComplete.get_element().disabled = false;
        } else {
            actorsAutoComplete.get_element().disabled = true;
            actorsAutoComplete.get_element().value = "";
        }
    }

    function cascade(sender, ev) {
        var actorsAutoComplete = $find('autoCompleteBehavior2');
        actorsAutoComplete.set_contextKey(ev.get_text());
        actorsAutoComplete.get_element().value = '';
        if (actorsAutoComplete.get_element().disabled) {
            actorsAutoComplete.get_element().disabled = false;
        }
    }   
    Sys.Application.add_load(initCascadingAutoComplete);

Calling the cascade function on the add_itemSelected method of the parent control for the cascading behaviour.

They cascade the contents of one auto complete extender into another, rather than taking a cascading drop down list, but hopefully you can reuse some of the ideas.

David Hall