Shows a textbox. When the user types in the textbox a list of suggestions is shown. The user can choose one suggestion from the list or continue writing. The control accepts values not in the list of suggestions.
"Textbox with autosuggest" works like a "textbox with dropdown" because it allows any text to be entered, even if it's not included in the list. But it also works like a "textbox with popup" as it continously searches a stored procedure for suggestions. The ”Auto” part is that the popup is opened automatically as you type and not on "tab".
The Control is best suited to autocompleating of names and search Words. If you want to replace a "textbow with popup", then you should use "textbox with autosearch" instead.
CREATE PROCEDURE Example.TextboxWithAutosuggestTable_TextboxWithAutosuggest @TopN int = 7, @Value varchar(max) AS BEGIN -- You have to use the escape function below, or else the control will crash if you search for %, , [^] and _ SELECT @Value = SoftadminUtil.String_EscapeLikeWildcards(@Value); SELECT DISTINCT TOP (@TopN) T.TextboxWithAutosuggestTableName FROM ( VALUES (1, 'alpha'), (2, 'beta'), (3, 'gamma'), (4, 'delta') ) AS T (TextboxWithAutosuggestTableId, TextboxWithAutosuggestTableName) WHERE T.TextboxWithAutosuggestTableName LIKE ISNULL(@Value, '') + '%'; END;
Always escape searched value.
SELECT @Value = SoftadminUtil.String_EscapeLikeWildcards(@Value);