By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,855 Members | 865 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,855 IT Pros & Developers. It's quick & easy.

How to clear Ajax Combobox with Javascript?

P: 2
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
Share this Question
Share on Google+
3 Replies


gits
Expert Mod 5K+
P: 5,282
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

P: 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...

Anyhow...

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>
  3.  
  4. (other stuff...)
  5.  
  6.  
  7. <cc1:ComboBox ID="comboBox1" OnTextChangedcomboBox1_TextChanged" Width="100px" Style="vertical-align: middle;" AutoCompleteMode="Suggest" runat="server">
  8. </cc1:ComboBox>
  9.  
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

gits
Expert Mod 5K+
P: 5,282
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.