469,324 Members | 1,414 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,324 developers. It's quick & easy.

How to clear Ajax Combobox with Javascript?

Has anyone figured out how to clear an Ajax combobox or remove the attached datasource using Javascript? I have tried numerous methods, done massive searches but keep coming up empty. I'm also finding that after I load my combobox with server-side code that when I highlight the first item in the list and press enter to clear it a javascript error is thrown. Anyone else seeing this?
Apr 29 '10 #1
3 4347
5,390 Expert Mod 4TB
what 'Ajax Combobox'? what error occurs? you would need to provide more information ... and probably some example code ... so that a reader might follow and could be able to identify the problem.

kind regards
Apr 30 '10 #2
Sorry if this is repeated, didn't see it from my first attempt:

Ok sorry, this is a pretty common problem that I have seen numerous users post on various websites, so I thought others would know without needing to give much detail...


Here's the problem...

I have a web page that I'm trying to use an Ajax Control Toolkit Combobox control with for displaying a list of values. Here is some of the aspx code:

Expand|Select|Wrap|Line Numbers
  1. <cc1:ToolkitScriptManager ID="ToolkitScriptManager2" runat="server">
  2. </cc1:ToolkitScriptManager>
  4. (other stuff...)
  7. <cc1:ComboBox ID="comboBox1" OnTextChangedcomboBox1_TextChanged" Width="100px" Style="vertical-align: middle;" AutoCompleteMode="Suggest" runat="server">
  8. </cc1:ComboBox>
Here is the server side code to load the control:

Expand|Select|Wrap|Line Numbers
  1. var codes = new List<Items>(Factory.GetInstance<proxy>().LookupSel ectedCodes(comboBox1.Text.ToUpper()));
  2. comboBox1.Items.Clear();
  3. comboBox1.Items.Add(new ListItem(string.Empty, string.Empty));
  4. foreach (var code in Codes)
  5. {
  6. var listItem = new ListItem(code.Name, code.Name);
  7. comboBox1.Items.Add(listItem);
  8. }
  9. comboBox1.SelectedIndex = 0;
  10. comboBox1.DataBind();
  11. if (Codes.Count > 1)
  12. comboBox1.SelectedIndex = 1;

Hopefully when I post this it will format in a way that makes it readable.

The problem occurs when, after the combobox has been loaded, if the user highlights the first item in the list and hits either the Backspace key or the Delete key it throws a javascript error: 'this._postBackSettings.async' is null or not an object" or something similar.

Hope this helps to explain the problem...
Apr 30 '10 #3
5,390 Expert Mod 4TB
that seems more like a ASP.NET question. i see that a JavaScript error occurs but obviously all this is encapsulated by the ASP.NET's Ajax Control Toolkit ... so i could move it for you to the ASP.NET forum ... think that you might get more responses there?

kind regards
May 1 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by bobzimuta | last post: by
3 posts views Thread by samoore33 | last post: by
1 post views Thread by www.web20developers.com | last post: by
2 posts views Thread by soni2926 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.