Archive

Archive for the ‘DefaultFocus’ Category

ASP.NET: DefaultButton and DefaultFocus

June 13th, 2008 Comments off

Since a while, on some of my company’s internet pages the DefaultButton and DefaultFocus properties did not work, although the code used seemed to be perfect. The problem was that the DefaultFocus javascript was not rendered at all.

After investigating the problem, I walked into two problems, solving which solved my problem as well:

1. DefaultButton requires a control’s UniqueID property, but DefaultFocus requires a control’s ClientID property. Strange, but it really works ASP.NET: DefaultButton and DefaultFocus icon smile !
2. Do not use hyphen characters in your ID properties (I had an auto ID using a GUID), since it will cause your focus to fail (the javascript is not being rendered). If you have or want to use some kind of separation, use the underscore character instead (it will work).

Hope that helps somebody out there too ASP.NET: DefaultButton and DefaultFocus icon wink !

Technorati tags: