Instruction:- In this we use this property
<form id="form1" runat="server" defaultfocus="TxtUserId">
Demo:-
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Set Default Focus On a Page Or Text Boxes</title>
</head>
<body>
<form id="form1" runat="server" defaultfocus="TxtUserId">
<div>
<h2 style="color:red">Default Focus </h2>
<table><tr><td>
<asp:Label ID="Label1" runat="server" Font-Bold="true" ForeColor="Orange" Text="User Name" >
</asp:Label>
</td>
<td>
<asp:TextBox ID="TxtUserName" runat="server" BackColor="Orange" >
</asp:TextBox>
</td>
</tr>
<tr><td>
<asp:Label ID="Label2" runat="server" Font-Bold="true" ForeColor="Orange" Text="User Id" >
</asp:Label>
</td>
<td>
<asp:TextBox ID="TxtUserId" runat="server" BackColor="Orange" > </asp:TextBox>
</td>
<tr><td colspan=2><center><asp:Button ID="Button1" runat="server" Font-Bold="true" ForeColor="Black" Text="Submit" /></center></td></tr>
</tr>
</table>
</div>
</form>
</body>
</html>
0 comments:
Post a Comment