Tuesday, May 10, 2011

Set focus on your content page upon loading

If you want 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%" class="canvas">
                                                <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

No comments:

Post a Comment