Tuesday, June 17, 2008

I had the ASP.NET problem that I could not give focus to my UserControl. I solved the problem by creating a method in my UserControl which overrides the Focus method of the Control class.

public override void Focus()
{
txtTextBox.Focus();
}

This only works in the 2.0 Framework and beyond. If you are using Framework 1.1, visit here:
http://ryanfarley.com/blog/archive/2004/12/21/1325.aspx