Tuesday 16 September 2008

JavaScript - Loop around properties of a textbox



var allprops="";
var count = 0;
for (var prop in RangeFromTextbox)
{
allprops += prop + "=" + RangeFrom[prop] + " \n" ;
if (count > 20)
{
alert(allprops);
allprops = "";
count = 0;
}
count++;
}
alert(allprops);

Tuesday 9 September 2008

Ajax Page Methods / Update Panels

Here is a blog post suggesting that UpdatePanels are often used in places where an Ajax Page Method would be better suited, it goes on to give an example of how to use Ajax Page Methods.

ASP.NET AJAX Page Methods


Heres another article with the same idea - Page Methods good, UpdatePanel bad.

Why ASP.NET AJAX UpdatePanels are dangerous

Monday 8 September 2008

Recursive function through controls



///
/// Recursive loop through form controls.
///

private void SetFormDisabled (Control control)
{
foreach (Control ctrl in control.Controls)
{
if (ctrl is TextBox)
{
((TextBox)(ctrl)).Enabled = false;
}
else if (ctrl is Telerik.WebControls.RadNumericTextBox)
{
((Telerik.WebControls.RadNumericTextBox)(ctrl)).Enabled = false;
}
else if (ctrl is CheckBox)
{
((CheckBox)(ctrl)).Enabled = false;
}
else
{
if (ctrl.Controls.Count > 0)
{
SetFormDisabled (ctrl);
}
}
}
}