---
title: "Show div instead of TextBox c#"  
description: "Show div instead of TextBox c#"  
author: "Anonymous User"  
published: 2014-01-27  
updated: 2014-01-27  
canonical: https://www.mindstick.com/forum/1885/show-div-instead-of-textbox-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# Show div instead of TextBox c#

I have 1 [TextBox](https://www.mindstick.com/forum/12714/dynamic-textbox-in-gridview) and 1 [Button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net). I want to display 5 div, if [user](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) enter 5 in the textbox and clicked the button for example.

I have this but I don't know how to make it to div

```
protected void Button1_Click(object sender, EventArgs e){    int NumberOfTextBoxes = Convert.ToInt32(TextBox_UserEntry.Text);    for (int i = 0; i < NumberOfTextBoxes; i++)    {        TextBox tb = new TextBox();        tb.ID = "tb" + Convert.ToInt32(i + 1);        Panel1.Controls.Add(tb);    }}can you help me to changeTextBox tb = new TextBox();tb.ID = "tb" + Convert.ToInt32(i + 1);Panel1.Controls.Add(tb);to div                <asp:TextBox ID="TextBox_UserEntry" runat="server"></asp:TextBox>                <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />                <asp:Panel ID="ParentPanel" runat="server">                </asp:Panel>div                <div id="divOccupantProfile">                <asp:Label ID="OPfamilyname" runat="server" Text="Family Name"></asp:Label>                <asp:TextBox ID="textOPfamilyname" runat="server"></asp:TextBox><br />                <asp:Label ID="OPfirstname" runat="server" Text="First Name"></asp:Label>                <asp:TextBox ID="textOPfirstname" runat="server"></asp:TextBox><br />                <asp:Label ID="OPmiddlename" runat="server" Text="Middle Name"></asp:Label>                <asp:TextBox ID="textOPmiddlename" runat="server"></asp:TextBox><br />                <asp:Label ID="OPmaritalstatus" runat="server" Text="Marital Status"></asp:Label>                <asp:DropDownList ID="ddlOPmaritalstatus" runat="server" >                    <asp:ListItem></asp:ListItem>                    <asp:ListItem>Married</asp:ListItem>                    <asp:ListItem>Single</asp:ListItem>                    <asp:ListItem>Divorced</asp:ListItem>                </asp:DropDownList><br />                <asp:Label ID="OPoccupation" runat="server" Text="Occupation"></asp:Label>                <asp:TextBox ID="textOPoccupation" runat="server"></asp:TextBox><br />                <asp:Label ID="OPrelationship" runat="server" Text="Relationship"></asp:Label>                <asp:DropDownList ID="ddlOPrelationship" runat="server" >                    <asp:ListItem></asp:ListItem>                    <asp:ListItem>Wife</asp:ListItem>                    <asp:ListItem>Daughter</asp:ListItem>                    <asp:ListItem>Son</asp:ListItem>                    <asp:ListItem>Father</asp:ListItem>                    <asp:ListItem>Mother</asp:ListItem>                    <asp:ListItem>House helper</asp:ListItem>                    <asp:ListItem>Driver</asp:ListItem>                </asp:DropDownList>  </div>
```

## Replies

### Reply by Pravesh Singh

Hi samuel,\

You can use Panel for this purpose. It renders as Div.

```
int NumberOfDiv = Convert.ToInt32(TextBox_UserEntry.Text);for (int i = 0; i < NumberOfDiv; i++){    Panel pnl = new Panel();    pnl.ID ="pnl" + Convert.ToInt32(i + 1);   
ParentPanel.Controls.Add(pnl);}
```


---

Original Source: https://www.mindstick.com/forum/1885/show-div-instead-of-textbox-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
