Here's the code from Helpers.cs
Code:
public static void SetInputControlsHighlight(Control container, string className, bool onlyTextBoxes)
{
foreach (Control ctl in container.Controls)
{
if ((onlyTextBoxes && ctl is TextBox) || ctl is TextBox || ctl is DropDownList ||
ctl is ListBox || ctl is CheckBox || ctl is RadioButton ||
ctl is RadioButtonList || ctl is CheckBoxList)
{
WebControl wctl = ctl as WebControl;
wctl.Attributes.Add("onfocus", string.Format("this.className = '{0}';", className));
wctl.Attributes.Add("onblur", "this.className = '';");
}
else
{
if (ctl.Controls.Count > 0)
SetInputControlsHighlight(ctl, className, onlyTextBoxes);
}
}
}
Now if you look at it, doesn't matter whether onlyTextBoxes is true or false, all form objects will get the onfocus and onblur actions. I have fixed the code to work correctly and here is the correct code:
Code:
public static void SetInputControlsHighlight(Control container, string className, bool onlyTextBoxes) {
foreach (Control ctl in container.Controls) {
if ((!onlyTextBoxes && ( ctl is TextBox || ctl is DropDownList ||
ctl is ListBox || ctl is CheckBox || ctl is RadioButton ||
ctl is RadioButtonList || ctl is CheckBoxList)) || (onlyTextBoxes && ctl is TextBox)) {
WebControl wctl = ctl as WebControl;
wctl.Attributes.Add("onfocus", string.Format("this.className = '{0}';", className));
wctl.Attributes.Add("onblur", "this.className = '';");
}
else {
if (ctl.Controls.Count > 0)
SetInputControlsHighlight(ctl, className, onlyTextBoxes);
}
}
}
Hope it helps someone :) I actually found out also that IE7 does not render onfocus for checkboxes but FF2 does render. I was testing both browsers and found out the highlight on FF2. As I didn't want it I changed the boolean to true at BasePage.cs. But the highlight was still there. Then I investigated the code and now it's fixed to work correctly.