Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
170
wrong events get fired in async postback
posted

hello,

i have couple of list boxes and check boxes in the webasyncrefreshpanel. the items listbox two depends on the items selected in the listbox one and also depends on whether the check boxes r checked or not. so the listboxes have their selectedindex changed event and the checkboxes have their checkchanged events. and as all of these controls are inside the webasyncrefreshpanel their ids are listed in the TriggerPostBackIDs property.

problem is when the item is selected for the first time from the first listbox the selectedindexchanged event gets fired once for it and it fills the second listbox accordingly and when an item is selected from the second listbox or the checkbox is checked then the selectedindexchanged event is ' fired for the first listbox without any reason ' before firing it for the second listbox or the checkbox.

so the point is that the selectedindexchanged events of the unexpected controls get fired when events of the expected controls get fired.

please help.

thank you.

Parents
No Data
Reply
  • 24497
    posted

    Hi,

    If you have controls inside of warp, then you do not have to set them as triggers. The TriggerPostBackIDs is designed for external controls.

    The problem that you described is known. I guess you use multiselection or something that triggers using extra view-state field by listboxes, otherwise, listbox raises on event without viewstate. Anyway, unfortunately I do not know how to fix that problem. The only suggestion that I have is to verify trigger of event while processing it. If postback is asynchronous and trigger is not what expected, then just exit handler. Example:

    protected void lstBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
     
    string id = this.Request.Form["__EVENTTARGET"];
     
    if(id != null && id.IndexOf("lstBox1") < 0)
       
    return;
      ...
    }

Children
No Data