Posted by : Anwar Hossain
Category : How to create control dynamically

Dynamically TextBox control creation in ASP.Net C #.

Dear viewer’s Sometimes we need to create ASP.Net Textbox programmatically or dynamically. In this tutorial I will show how to create ASP.Net Textbox Control dynamically in ASP.Net C #. For creating ASP.Net Textbox Control I have created a function and called the function page load event. I have used for loop to create multiple Textbox but without using loop one Textbox Control can be created.

Dynamically TextBox control creation in ASP.Net C #.


<html >

<head runat="server">

    <title>Create textbox dynamically  </title>



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








using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Drawing;


public partial class createtextbox : System.Web.UI.Page


    protected void Page_Load(object sender, EventArgs e)




        //Create textbox dynamically




    private void CreateTexbox()



        //limit to ceate textbox

        int a = 15;

        for (int i = 0; i < a; i++)


            TextBox txtDynamic = new TextBox();


            //Declaring the textbox ID name


            txtDynamic.ID = "tb" + "" + ViewState["MyText"] + i + "<br/>";


            txtDynamic.Width = 400;

            txtDynamic.Height = 20;


            txtDynamic.BorderStyle = BorderStyle.Solid;

            txtDynamic.Style["Top"] = "25px";

            txtDynamic.Style["Left"] = "100px";

            txtDynamic.BackColor = Color.DarkGray;

            txtDynamic.BorderColor = Color.Coral;

            txtDynamic.TextMode = TextBoxMode.MultiLine;









Out Put

Realted Article Headline

Dynamically Label control creation in ASP.Net C #.
Dynamically TextBox control creation in ASP.Net C #.

Article Category

How to create control dynamically
Learn HTML for beginner
DataList example in C Sharp
Mail sending in c#
State Management in ASP C #
Basic sql tutorial for Beginner
DataTable example in ASP.Net C#
How to use LINQ in ASP.NET C# c # basic tutorial
How to use ajax toolkit in C#
How to use different types of validation control using c#
How to use grid view in c#
Protected by Copyscape Online Plagiarism Detection