Newbie question about set focus to a textbox field

Discussion in 'ASP .Net' started by =?Utf-8?B?eGNvbXBsdXM=?=, Apr 22, 2004.

  1. I am new to .net web development and have a simple question that has been asked for many times. However, by reading the postbacks, I still cannot fig out how to do it. In a Login.aspx page, I have two textbox fileds (UserID and Password) and a Button (Login), all of them are server controls. The code for the Login Button located in the Login.aspx.cs file will check the user is a valid one though records in a database. If the checking failed, I want to put the input focus on the UserID filed through client side script, not by redirect to the Login page itself. I notice that it can be done though way of emitting client side script, i.e., using RegisterClientScriptBlock call in the cs file. But I do not know exactly how to do it. Can somebody pass me sample code that works

    Many thanks in advance

    Following is the html code for the login.aspx pag
    <%@ Page Language="c#" AutoEventWireup="false" CodeBehind="Login.aspx.cs" Inherits="TestWeb.Login" %><HTML><body><form runat="server"><table height="81"><tr><td>UserID:</td><td><asp:TextBox id="UserEmail" runat="server" /></td></tr><tr><td>Password:</td><td><asp:TextBox id="UserPass" TextMode="Password" runat="server" /></td></tr></table><asp:Button id="Login" runat="server" Text="Login"></asp:Button></form></body></HTML>
     
    =?Utf-8?B?eGNvbXBsdXM=?=, Apr 22, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mg

    Set focus on a TextBox

    mg, Jul 14, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    488
    dj Bass
    Jul 14, 2003
  2. sumit
    Replies:
    1
    Views:
    907
  3. Grey
    Replies:
    1
    Views:
    2,170
    Saravana [MVP]
    Jun 18, 2004
  4. Replies:
    2
    Views:
    343
    Thomas 'PointedEars' Lahn
    Jun 6, 2005
  5. Roger
    Replies:
    3
    Views:
    336
Loading...

Share This Page