How do you remove a focus ring programatically

On a WebForm a User selects a field or I set the focus of a field with SetFocus, then I disable the field for whatever reason. The field is disabled, but a dimmed focus ring remains. How do I get rid of the focus ring.

Thanks,

John

[quote=206697:@John Baughman]On a WebForm a User selects a field or I set the focus of a field with SetFocus, then I disable the field for whatever reason. The field is disabled, but a dimmed focus ring remains. How do I get rid of the focus ring.
[/quote]

I cannot reproduce what you describe here. When a field is disabled, it loses the focus ring.

However, the simplest way to remove the focus ring is to set focus to another field. What you can do is place an invisible TextField above the webpage (say with Top = -100), to which you set focus when you want to clear focus from all fields.

You can also set all TextFields with no focus ring.

Interesting that you cannot reproduce it. I the particular case that I am seeing the focus ring remain, I have just previously set it to selected with a focus ring in the selection changed event of a list box. If a row was in fact selected, the text field is enabled and focused. If the user subsequently clicks the listbox such that no rows are selected, the text field is emptied, and disabled. In my case the focus ring remains.

I figured I could use an invisible field to lose the focus, but was wondering if it could be done otherwise. I do the same thing in anaother non xoxo project

Thanks, I will use and invisible object for this purpose as you suggest.

John

@michel bulteau For me the dummy text field does not get the focus if it is invisible. Are you able to use and invisible text field? Just curious. I put it way off the scren so it really does not matter.

There is no ClearFocus in Web, so the quickest way was a catcher control.

You can also use the JavaScript blur() method to remove the focus.

If you read carefully what I wrote, I never said to make the catcher invisible, just that it was invisible because it was above the Webpage at top = -100.

You seem to have discovered the same technique.