How to set Focus on TextBox(in User), I am using modelpop extender for login?

Last post 05-01-2009 12:34 PM by pankajajax. 4 replies.

Sort Posts:

  • How to set Focus on TextBox(in User), I am using modelpop extender for login?

    04-30-2009, 5:45 PM
    • Member
      33 point Member
    • pankajajax
    • Member since 03-06-2008, 12:13 PM
    • Bangalore
    • Posts 75

    Hi All,

    How to set focus in textbox(UserName) , I am using ModelPopExtender for Login,When page loads

    that time modelpop is displayed for login purpose so initally i want focus on username textbox.

    Here is my code.

      protected void Page_Load(object sender, EventArgs e)
        {
            
            ModalPopupExtender1.Show();
           
        }

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" EnableEventValidation="false"%>


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Untitled Page</title>
        <link href="css/StyleSheet.css" rel="stylesheet" type="text/css" />   
       
    </head>
    <body >
    <form id="form1" defaultfocus="txtUserName" runat="server" >
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnableScriptGlobalization="true" EnableScriptLocalization="true">
    </asp:ScriptManager>
      <div>
       <asp:Button runat="server" ID="btnShowModalPopup" style="display:none"/>
             <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1"
                    runat="server" TargetControlID="btnShowModalPopup" PopupControlID="LoginPanel"
                    BackgroundCssClass="modalBackground" DropShadow="true" CancelControlID="btnCancel"/>         
       
        <asp:Panel ID="LoginPanel" runat="server" CssClass="modalPopup" Style="display: none" Width="394px" Font-Names="@MS PGothic" Height="200px" DefaultButton="btnLogIn">
                 <div style="text-align:center;font-size: 15pt;background-color:#990000; color:#FFFFCC; height:25px; width: 382px;">
                        <p>Wave Reader Log In</p>
                    </div>
               <br />
                <table style="width: 386px; height: 108px;">
                    <tr>
                        <td style="width: 30px " align="right" valign="top">
                            <div style="text-align:right;font-size: 15pt;background-color:#990000; color:#FFFFCC;">
                            <asp:Label ID="Label10" runat="server" Height="23px" Text="UserName :"></asp:Label></div>
                        </td>
                        <td style="width: 179px" align="left" valign="top">
                            <asp:TextBox ID="txtUserName" runat="server" Width="115px" TabIndex="1"></asp:TextBox>
                           
                            <asp:Label ID="lblUserNameRequired" runat="server" ForeColor="Red" Width="271px"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 30px " align="right" valign="top">
                            <div style="text-align:right;font-size: 15pt;background-color:#990000; color:#FFFFCC;">
                            <asp:Label ID="Label9" runat="server" Height="23px" Text="Password :"></asp:Label></div>
                        </td>
                        <td style="width: 179px" align="left" valign="top">
                            <asp:TextBox ID="txtPassword" runat="server" Width="115px" TextMode="Password" TabIndex="2"></asp:TextBox>
                            <asp:Label ID="lblPasswordRequired" runat="server" ForeColor="Red" Width="271px"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 94px">
                        </td>
                        <td style="width: 179px" align="left">
                          
                            <asp:Button ID="btnCancel" runat="server" Text="Cancel" Width="52px" TabIndex="4"/>
                            <asp:Button ID="btnLogIn" runat="server" Text="Log In" OnClick="LoginBtn_Click" TabIndex="3" />
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 94px">
                        </td>
                        <td style="width: 179px" align="left">
                            <asp:Label ID="lblMessage" runat="server" ForeColor="Red" Width="276px"></asp:Label>
                        </td>
                    </tr>
                </table>
            <br />
          
        </asp:Panel>
        <br />
       
       </div>

    </form>
    </body>
    </html>

  • Re: How to set Focus on TextBox(in User), I am using modelpop extender for login?

    04-30-2009, 7:42 PM
    Answer
    • Participant
      1,556 point Participant
    • RemithR
    • Member since 01-19-2009, 7:46 PM
    • Posts 271

    There is a very good article explaining ModalPopup Extender with PostBack and Set Focus at

    http://www.aspdotnetcodes.com/ModalPopup_Postback.aspx

    Please check whether this helps you.

  • Re: How to set Focus on TextBox(in User), I am using modelpop extender for login?

    05-01-2009, 2:28 AM
    • Contributor
      2,570 point Contributor
    • anup1252000
    • Member since 11-12-2008, 8:26 AM
    • india
    • Posts 519

     in the for tag set defaultfocus="textbox(UserName)" give ur textbox id i wil do the rest..

    Remember to click “Mark as Answer” on the post, if it helps you. Because It helps others to find the solution.

    Anup Hosur
    HP
    http://anup-anuphosur.blogspot.com/


  • Re: How to set Focus on TextBox(in User), I am using modelpop extender for login?

    05-01-2009, 2:30 AM
    • Contributor
      2,570 point Contributor
    • anup1252000
    • Member since 11-12-2008, 8:26 AM
    • india
    • Posts 519

     sorry spelling mistake.. i mean in form tag.. write like this

    <form id="form1" runat="server" defaultfocus=txtuser">

    Remember to click “Mark as Answer” on the post, if it helps you. Because It helps others to find the solution.

    Anup Hosur
    HP
    http://anup-anuphosur.blogspot.com/


  • Re: How to set Focus on TextBox(in User), I am using modelpop extender for login?

    05-01-2009, 12:34 PM
    Answer
    • Member
      33 point Member
    • pankajajax
    • Member since 03-06-2008, 12:13 PM
    • Bangalore
    • Posts 75

     Thanks for this reply.

Page 1 of 1 (5 items)
Microsoft Communities