Building Infragistics Gauges in WebPart

Recently, I employ the Infragistics controls for a client project where personnel data had to be displayed in a dashboard-like format, the Gauge (UltraGauge) control being the most popular within the organization. There was some pre-existing ad-hoc development, so I got to examine numerous variations of how to suitably instantiate the various Infragistics components.

Consider the below GaugeBuilders class. The BasicGaugeFactory method consumes an id string since the UltraGauge.ID property is the only diverse property between UltraGauges on instantiatation. While this hydrates the object with the sufficient properties, the QueryAndAssignGaugeValues method consumes the UltraGauge control and an integer representing the value to set the gauge at. Since there are various Types of UltraGauges so value setting contrasts, such as RadialGauge, SegmentedDigitalGauge, LinearGauge, UltraGauge.GetType() has to be tested, probably in a not so efficient format.

Arguably, the two of these could easily be merged into one method, whereby the gauge is created and set within a single call. Or QueryAndAssignGaugeValues could just be called after UltraGauge.LoadPreset. It’s really just a preference.

using System;
using System.Web.UI.WebControls;
using Infragistics.UltraGauge.Resources;
using Infragistics.WebUI.UltraWebGauge;

namespace infragistics.Generic
public class GaugeBuilders
public static UltraGauge BasicGaugeFactory(string id)
var gauge = new UltraGauge {ID = id, Height = Unit.Pixel(250), Width = Unit.Pixel(250)};
WebGaugeDeploymentScenario deployment = gauge.DeploymentScenario;
deployment.Mode = ImageDeploymentMode.FileSystem;
deployment.FilePath = “~/GaugeImages”;
deployment.ImageURL = “~/GaugeImages/gauge_month_#SEQNUM(100).png”;
deployment.ImageTQpe = GaugeImageType.Png;
gauge.LoadPreset( @”Path_To_Your_XML_Structure_FIle “, true);
return gauge;

public static void QueryAndAssignGaugeValues(UltraGauge gaugeParameter, int number)
foreach (Gauge gauge in gaugeParameter.Gauges)
Type gaugeType = gauge.GetType();
if (Equals(gaugeType, typeof (RadialGauge)))
var rg = (RadialGauge) gauge;
rg.Scales[0].Markers[0].Value = number;
if (Equals(gaugeType, typeof (SegmentedDigitalGauge)))
var rg = (SegmentedDigitalGauge) gauge;
rg.Text = number.ToString();
if (Equals(gaugeType, typeof (LinearGauge)))
var rg = (LinearGauge) gauge;
if (rg.Scales[0] != null)
rg.Scales[0].Markers[0].Value = Convert.ToInt32(number);



  1. Steve Christopherson says:

    This is a lot better than the infragistics example, at least it is reasonable to follow.

  2. fahim says:

    Kindly tell me how we add Infragistics.UltraGauge.Resources namespace in C#
    I simply wrote using “Infragistics.UltraGauge.Resources ” but it gives me an error
    Thanks in Advance

Leave a Reply

Your email address will not be published. Required fields are marked *