Set focus on your content page upon loading

If you wnat to set focus on the content page, put your javascript on <head> tag, then call the function using onload event on the body. Then create an id on the part that you wish to set focus.

<head runat=”server”>
    <asp:ContentPlaceHolder ID=”head” runat=”server”>
    <link href=”Template.css” rel=”stylesheet” type=”text/css” />
    <link href=”Main_Menu.css” rel=”stylesheet” type=”text/css” />
    <link type=”text/css” href=”css/ui-lightness/jquery-ui-1.8.12.custom.css” rel=”stylesheet” />
    <style type=”text/css”>



<body onload=”setFocus()”>
    <form id=”form1″ runat=”server”>

<table border=”0″ cellpadding=”0″ cellspacing=”0″ width=”100%”>
                    <td valign=”top” id=”contentPage”>


Javascript focus method

This entry was posted in ASP.NET 3.5 And JavaScript, ASP.NEt And C# 3.5 And Javascript, JavaScript. Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s