locked
NotFoundError in UI.js when using searchbox

    Question

  • I am getting a NotFoundError in UI.js on line 27240 when I search using the searchbox control and quickly navigate to another page.  The search control is on the home page and on search the app navigates to the results page.  Any tips on navigation with searching would be appreciated.  It seems that the UI is trying to update the searchSuggestion UI component after navigation.

    function searchSuggestionEventHandler(eventObject) {
            try {
                if (eventObject && eventObject.detail && eventObject.detail.queryText) {
    
                    if (searchPromise && searchPromise.cancel) {
                        searchPromise.cancel();
                    }
    
                    var queryText = eventObject.detail.queryText;
                    var suggestionCollection = eventObject.detail.searchSuggestionCollection;
                    if (queryText.length > 1) {
    
                        var searchPromise = new WinJS.Promise(function (complete) { Data.searchParts(queryText).then(function (results) { complete(results) }) });
    
                        eventObject.detail.setPromise(searchPromise.then(function (results) {
                            if (results.length > 0) {
                                var limit = (results.length < 6) ? results.length : 5;
                                for (var i = 0; i < limit; i++) {
                                    var suggestion = results[i].salesDescription || "";
                                    try {
                                        
                                        if (suggestionCollection) {
                                            suggestionCollection.appendQuerySuggestion(suggestion);
                                        } else {
                                            return;
                                        }
                                    } catch (e) {
                                        return;
                                    }
                                }
                            }
                        }, function (error) {
                            return error;
                        }));
                    }
                }
            } catch (e) {
                return e;
            }
        }


    Saturday, February 01, 2014 9:16 PM

All replies

  • Hi Andrew,

    The error message seems cannot find the object, and may I know if you are using both SearchPane and SearchBox control in the same project?

    An app can't use both the search box (Windows.UI.Xaml.Controls.SearchBox for Windows Store apps using C++, C#, or Visual Basic, WinJS.UI.SearchBox for Windows Store apps using JavaScript) and the SearchPane. Using both the search box and the search pane in the same app causes the app to throw an exception with this message: "Cannot create instance of type 'Windows.UI.Xaml.Controls.SearchBox.'"

    And if the app cannot create the SearchBox, of course the code cannot find the correct object.

    For using the SearchBox, plz ref to: http://msdn.microsoft.com/en-us/library/windows/apps/hh465238.aspx, meanwhile SearchBox control sample could be a good sample.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.



    Tuesday, February 04, 2014 2:53 AM
    Moderator
  • No the app only uses the search box
    Wednesday, February 26, 2014 10:31 PM
  • Seems I provide a wrong direction, is your problem solved?  Or could you provide some more detail information.


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, February 27, 2014 7:40 AM
    Moderator