Quantcast
Channel: AjaxControlToolkit Work Item Rss Feed
Viewing all articles
Browse latest Browse all 4356

Commented Issue: ComboBox throws NullReferenceException on PostBack when created but not rendered [26981]

$
0
0
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); } } }

Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>