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>