TextBox 1 개와 버튼 1 개가 있습니다. 사용자가 텍스트 상자에 5를 입력하고 예를 들어 버튼을 클릭하면 5 div
을 표시하려고합니다.TextBox 대신 div를 표시합니다. C#
나는 이것을 가지고 있지만
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);
}
}
당신이 날
TextBox tb = new TextBox();
tb.ID = "tb" + Convert.ToInt32(i + 1);
Panel1.Controls.Add(tb);
<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를 변경하는 데 도움이 될 수는 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>
ASP.NET WebForms이 좋으시겠습니까? –
예 @SergeyBerezovskiy 예 : @SergeyBerezovskiy –