How to set focus on first textbox of the page

Category > ASP.NET || Published on : Thursday, February 11, 2016 || Views: 7915 || How to set focus on first textbox of the page


Introduction

Here Pawan Kumar will explain How to set focus on first textbox of the page

Description

In previous post I have explained How to find third highest salary in sql server., How to prevent input field from special character, How to display image on image selection using fileupload control in JQuery., Add TextBox Dynamically ASP.Net on Click ASP.Net Button, Mask UnMask Input Text jQuery Html, JavaScript Alert Message Dialog Box, and many more articles.

Now I will explain How to How to set focus on first textbox of the page

So follow the steps to learn How to set focus on first textbox of the page
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>SourceCodeHub.com</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('form input:text:enabled:first').focus();
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:TextBox ID="TextBox1" runat="server" />
  
    <asp:TextBox ID="TextBox2" runat="server" />
  
    <asp:TextBox ID="TextBox3" runat="server" />
  
    <asp:TextBox ID="TextBox4" runat="server" />
  
    </form>
</body>
</html>

 

Conclusion:

So, In this tutorial we have learned, How to set focus on first textbox of the page