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?
How to clear Ajax Combobox with Javascript?
Collapse
X
-
Tags: None
-
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:
Here is the server side code to load the control:Code:<cc1:ToolkitScriptManager ID="ToolkitScriptManager2" runat="server"> </cc1:ToolkitScriptManager> (other stuff...) <cc1:ComboBox ID="comboBox1" OnTextChangedcomboBox1_TextChanged" Width="100px" Style="vertical-align: middle;" AutoCompleteMode="Suggest" runat="server"> </cc1:ComboBox>
Code:var codes = new List<Items>(Factory.GetInstance<proxy>().LookupSel ectedCodes(comboBox1.Text.ToUpper())); comboBox1.Items.Clear(); comboBox1.Items.Add(new ListItem(string.Empty, string.Empty)); foreach (var code in Codes) { var listItem = new ListItem(code.Name, code.Name); comboBox1.Items.Add(listItem); } comboBox1.SelectedIndex = 0; comboBox1.DataBind(); if (Codes.Count > 1) 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._postBack Settings.async' is null or not an object" or something similar.
Hope this helps to explain the problem...Comment
-
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 regardsComment
Comment