How to set focus on control in C#

Category > ASP.NET || Published on : Wednesday, April 7, 2021 || Views: 2189 || set focus on control in C#


Here Pawan Kumar will explain how to set focus on control in C#


In previous post I have explained Assign datepicker to runtime/dynamic textboxes in ASP.NET using jQuery, Show Asp.Net Gridview Row Details using Bootstrap Tooltip on MouseHover GridView Row Cell, Best 7 Resources for 3 tier architecture Asp.Net, Show Hide Password Using Javascript ASP.NET, How to Create Tab Control Using jQuery In Asp.Net, jQuery Datepicker Calendar With Slide Down Effect In Asp.Net, and many more articles.

Now I will explain How set focus on control in C#


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

<!DOCTYPE html>

<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
            <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>

Code Behind Codes:-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class test : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)


So, In this tutorial we have learned, how to set focus on control in C# In Asp.Net

Download Source Codes