Implementing AutoPostBack on Infragistics WebCombo

Posted by andy gaskell on Apr 1st, 2006

I use Infragistics NetAdvantage control suite for UI development at work. If you hate UI development like me, these tools can help out tremendously. While working with their WebCombo control, a much more powerful version of the ASP.Net DropDownList control – I noticed the WebCombo was sorely missing is the AutoPostBack property.

I’ll be explaining how to implement an AutoPostBack property on a UserControl that contains a single Infragistics WebControl.

On your HTML page, add the following tag after the end of your opening WebCombo tag:


<CLIENTSIDEEVENTS AfterSelectChange="itgtbl_needPostBack('{0}')"></CLIENTSIDEEVENTS>

Create a basic AutoPostBack property on the codebehind of your UserControl.

protected bool autoPostBack;

public bool AutoPostBack
{
     get{return this.autoPostBack;}
     set{this.autoPostBack = value;}
}

Now you need to add a method that either sets up your WebCombo so that it automatically posts back, or does not generate any client code to post back. You can decide when you want to call this method in your code

private void SetupAutoPostback()
{
     if(this.autoPostBack)
     {
          string gridClientID = string.Empty;

          foreach(Control control in this.YOUR_COMBO_HERE.Controls)
          {
               Infragistics.WebUI.UltraWebGrid.UltraWebGrid grid = control as Infragistics.WebUI.UltraWebGrid.UltraWebGrid;

               if(grid != null)
               {
                    gridClientID  = grid.ClientID;
                    break;
               }
          }

          this.YOUR_COMBO_HERE.ClientSideEvents.AfterSelectChange = string.Format(this.YOUR_COMBO_HERE.ClientSideEvents.AfterSelectChange, gridClientID);
     }
     else
     {
          this.YOUR_COMBO_HERE.ClientSideEvents.AfterSelectChange = string.Empty;
     }
}

Run your page – your combo should now post back automatically when the selected index changes.

Technorati Tags: , ,

6 Responses

  1. Leela Says:

    Hello sir,

    Where can i call this function “SetupAutoPostback”.I call this function in ultrawebgrid click event but it is not working.

    Actually i have webcombo1 which is placed inside ultrawebgrid in first cell.I need webcombo1_selectedindexchange during the postback.But it did’nt.What shall i do.& where can i call these functions such as SetupAutoPostback,AutoPostBack

  2. Fred Kazarian Says:

    Hi

    I am having the oposite problem. The WebCombo posts back everytime I select an item from it. I am using NetAdvantage for .NET 2007 Volume 1 CLR 2.0.

    Is there a way to turn off AutoPostback?

    Thanks
    Fred

  3. Ramki Says:

    I am using custom control hence not able add the following line html tag

    How to implement the AutPost Back in custom control by inheriting the infragistics webcombo.

    Any help is appreciated.

  4. infra_hater Says:

    See how confusing infragistics controls are,, the author says there is no autopostback then Fred says his posts back,,,, I want to screeeeeeeeeeem

  5. easy when you know Says:

    if you don’t add clientsideevent for “AfterSelectChange” and add a server event handler the webcombo will auto postback

  6. easy when you know Says:

    even if you just add server event handler it will auto postback unless you stop the postback in the client event

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.