Newbie question about set focus to a textbox field

Discussion in 'ASP .Net' started by Guest, Apr 22, 2004.

  1. Guest

    Guest Guest

    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>
    Guest, Apr 22, 2004
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.