[FIXED] [V0.7] LoadPostData() results in NullReferenceException

  1. #1

    [FIXED] [V0.7] LoadPostData() results in NullReferenceException

    <p class="MsoNormal"></p><p class="MsoNormal"></p><p class="MsoNormal">Hello All,</p>

    <p class="MsoNormal">Today I ran into a strange issue with Coolite form elements
    that I would like to share with the community. </p>

    <p class="MsoNormal">Long story short, we have a custom server control that
    initiates ICallback requests on various client side events. When we mixed
    Coolite in all of a sudden the ICallback requests started throwing null reference
    errors. Bellow is an example stack trace.</p>
    [NullReferenceException: Object reference not set to an instance of an object.]
       Coolite.Ext.Web.Hidden.set_Value(Object value) +73
       Coolite.Ext.Web.Hidden.LoadPostData(String postDataKey, NameValueCollection postCollection) +160
       Coolite.Ext.Web.Field.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) +11
       System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +661
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1194
     
    As it would turn out, the ICallback request was not posting all of the form elements Coolite was expecting. Three different form elements chocked on  null value posts. After a few minor tweeks to the following pieces of code the ICallback requests resumed working.
    public virtual string Text
    {
        get
        {
            return (string)this.ViewState["Text"] ?? "";
        }
        set
        {
            this.ViewState["Text"] = value;
        }
    }
    NumberField.cs
    protected override bool LoadPostData(string postDataKey, NameValueCollection postCollection)
    {
        string val = postCollection[this.UniqueName];
       
        if (!this.ReadOnly &amp;&amp; !this.Text.Equals(val))
        {
            try
            {
                this.ViewState.Suspend();
                this.Text = val != null &amp;&amp; val.Equals(this.EmptyText) ? "" : val;
            }
            finally
            {
                this.ViewState.Resume();
            }
            return true;
        }
        return false;
    }
    Hidden.cs
    public override object Value
    {
        get
        {
            return (string)this.ViewState["Value"] ?? "";
        }
        set
        {
            this.ViewState["Value"] = value != null ? value.ToString() : null;
        }
    }
    <p class="MsoNormal">Cheers!</p>

    </p>

    </p>

    </p>
  2. #2

    RE: [FIXED] [V0.7] LoadPostData() results in NullReferenceException

    Hi disbell,

    Thanks for pointing out the NullReference issue.

    We have gone through the controls and corrected the problem.

    This fix will be available with the v0.7 release.

    Geoffrey McGill
    Founder

Similar Threads

  1. [CLOSED] Highlight search results
    By bakardi in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 21, 2012, 7:58 PM
  2. [CLOSED] ComboBox keyboard navigation for grouped results
    By prointernet in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 12, 2011, 10:35 AM
  3. [CLOSED] LoadPostData() of TreePanel within Combobox / Lazy load
    By pschojer in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Nov 05, 2009, 3:29 AM
  4. Replies: 3
    Last Post: Oct 02, 2009, 6:04 AM
  5. Replies: 1
    Last Post: Sep 04, 2009, 9:32 AM

Posting Permissions