Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hello

i use from ajaxcontroltoolkit for a combobox.
for search sometimes i nead to cleat text property of my combobox until search method return all record (without filter)
but the command (mycombobox.text = "") dont work. why?

Thanks

What I have tried:

i could't do any things...

help
Posted
Updated 21-Nov-18 5:52am
Comments
F-ES Sitecore 21-Nov-18 5:30am    
If you're executing this code server-side then you won't see the combobox clear in the browser until the component has been updated, either until the page has finished executing, or if you're doing this via ajax until that process has finished and the front-end updated.

The problem will be to do with the context that you're clearing the combobox which we don't really know. You'll have to provide a bit more information about what you're doing.

1 solution

The AjaxControlToolkit ComboBox behaves similarly as the standard ASP.NET DropDownList control, so technically, you can't clear the text just what you normally do with the standard TextBox control using the .Text property.

What you can do is insert an empty value to your ComboBox like this on Page_Load event:

C#
ComboBox1.Items.Insert(0, New ListItem(""))


Now, this will put an empty string in your ComboBox list. You can then call:

C#
ComboBox1.ClearSelection();


to reset the SelectedIndex to the default item or you could remove the empty value if you'd like something like:

C#
ComboBox1.Items.Remove("");
 
Share this answer
 
v2
Comments
F-ES Sitecore 21-Nov-18 11:54am    
It's actually a combination text box and dropdown, more akin to what is available in win forms.
Vincent Maverick Durano 21-Nov-18 12:03pm    
Right. What I meant is you can't set the .Text value just like what we normally do with TextBox, it behaves like a DropDownList control where you can't set the .Text property.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900