Ajax Control Toolkit version: 3.5.50508
The ComboBox throws a NullReferenceException when it is created and added to the Controls collection but not rendered (ComboBox,Enabled = true, ComboBox.Visible = true). This is being caused by the following code fragment within ComboBox.LoadPostData:
if (this.Enabled)
{
int newSelectedIndex = Convert.ToInt32(postCollection.GetValues(this.HiddenFieldControl.UniqueID)[0], CultureInfo.InvariantCulture);
....
}
It should check if postCollection.GetValues(this.HiddenFieldControl.UniqueID) has a value before performing the conversion.
Comments: @y_chen: I have created my own ComboBox class which 'replaces' the LoadPostData method: public class ComboBox : AjaxControlToolkit.ComboBox { protected override bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection) { if (postCollection.GetValues(this.HiddenFieldControl.UniqueID) == null) { return false; } else { return base.LoadPostData(postDataKey, postCollection); } } }
The ComboBox throws a NullReferenceException when it is created and added to the Controls collection but not rendered (ComboBox,Enabled = true, ComboBox.Visible = true). This is being caused by the following code fragment within ComboBox.LoadPostData:
if (this.Enabled)
{
int newSelectedIndex = Convert.ToInt32(postCollection.GetValues(this.HiddenFieldControl.UniqueID)[0], CultureInfo.InvariantCulture);
....
}
It should check if postCollection.GetValues(this.HiddenFieldControl.UniqueID) has a value before performing the conversion.
Comments: @y_chen: I have created my own ComboBox class which 'replaces' the LoadPostData method: public class ComboBox : AjaxControlToolkit.ComboBox { protected override bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection) { if (postCollection.GetValues(this.HiddenFieldControl.UniqueID) == null) { return false; } else { return base.LoadPostData(postDataKey, postCollection); } } }