Use the input focus capability of ASP.NET 2.0 and superior : Controls « Page Lifecycle « ASP.NET Tutorial






<%@ Page language="C#" %>

<script runat="server">
   void Page_Load(object sender, EventArgs e)
   {
       if (!IsPostBack)
           this.SetFocus("Pswd");
   }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Focus to the control</title>
</head>
<body>
    <div id="pageContent">
        <form id="Form1" runat="server">
            <h1>Please, login</h1>
            <h3>User</h3>
            <asp:textbox runat="server" id="UserName" text="" /><br />
            <h3>Password</h3>
            <asp:textbox runat="server" id="Pswd" text="" TextMode="Password" /><br />
            <asp:button runat="server" id="Login" text="Log in" />
            <hr />
        </form>
    </div>
</body>
</html>








5.11.Controls
5.11.1.Controls.Count
5.11.2.Add a control to a page dynamically
5.11.3.Grab Browser Info
5.11.4.Use the input focus capability of ASP.NET 2.0 and superior