In some cases when an ASP.NET page loads the control, you need to focus on is not visible because it is further down the page. I have had numerous occasions when a request variable indicates which item on a long list the user is interested in viewing, this script can help by scrolling the particular item into view.
The following function I have added to a Utils.dll library for general use so is static and needs the current page as a variable.
public class Utils
public static void FocusControlOnPageLoad(string ClientID,
var el = document.getElementById('"+ClientID+@"')
if (el != null)
window.onload = ScrollView;
You can use this as follows:
private void Page_Load(object sender, System.EventArgs e)
Hopes this helps someone.