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: , ,

Making the webbrowser control synchronous

Posted by andy gaskell on Apr 1st, 2006

Here’s a little trick if you need to make the WebBrowser control behave synchronously instead of having to hookup to the DocumentCompleted event. Attaching/unattaching from that event makes code pretty messy. Anyway, here’s my solution – it works :)

this.webBrowser.Navigate(url);

while (this.webBrowser.ReadyState != WebBrowserReadyState.Complete)
{
     Application.DoEvents();
}

So simpo.

Technorati Tags: ,

Variable variables in PHP

Posted by andy gaskell on Apr 1st, 2006

While learning PHP I came across a feature that’s completely new to me – variable variables. With variable variables you can dynamically assign variable names and reference those dynamic names. I understand how they work, I’m just not sure how useful they’d be. I suppose an array of variable variables could pass as a poor man’s Hashtable or NameValueCollection.

Here’s some code that demonstrates variable variables:

<?php
     $recipe = "beans";
     $$recipe = "& big ideas";

     echo("$recipe $beans");
     echo("<br/>");
     echo("$recipe ${$recipe}");
?>

Here’s the output:

beans & big ideas
beans & big ideas

Technorati Tags: ,