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”>
    <title></title>
    <asp:ContentPlaceHolder ID=”head” runat=”server”>
    </asp:ContentPlaceHolder>
    <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”>

</head>

….

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

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

….

Javascript focus method
http://www.bloggingdeveloper.com/post/Setting-Focus-Using-Javascript-to-an-Input-Field-(Textbox)-when-the-Page-Loads.aspx
http://forums.htmlhelp.com/index.php?showtopic=5399
http://www.roseindia.net/javascript/javascript-focus-method.shtml

Advertisements
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:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s