如何创建可以生成自己的字段和新面板的 ASP.NET C#?

How create an ASP.NET C# that can generate its own field and and new panels?

我正在尝试创建一个 Web 应用程序,它可以像 google 表单一样创建调查表单。

<asp:Panel ID="container" runat="server"></asp:Panel>
<asp:Panel ID="question" runat="server" Height="391px">
    <br />
    <br />
    <asp:Label ID="Label1" runat="server" Text="Question:  " Font-Size="Large"></asp:Label>
    <asp:TextBox ID="txtQuestion" runat="server" Font-Size="Large"></asp:TextBox>
    <asp:DropDownList ID="lstQuestionType" runat="server">
        <asp:ListItem Enabled="False" Selected="True">Question Type</asp:ListItem>
        <asp:ListItem>Short Answer</asp:ListItem>
        <asp:ListItem>Paragraph</asp:ListItem>
        <asp:ListItem>Multiple Choice</asp:ListItem>
        <asp:ListItem>Check Box</asp:ListItem>
        <asp:ListItem>Linear Scale</asp:ListItem>
    </asp:DropDownList>
    <asp:Button ID="btnGenerate" runat="server" OnClick="btnGenerate_Click" Text="Generate Question" Width="137px" />
</asp:Panel>

<asp:Button ID="btnAddQuestion" runat="server" Text="Add Question" OnClick="btnAddQuestion_Click" />

这是生成面板的 C# 代码

protected void btnAddQuestion_Click(object sender, EventArgs e)
{
    Panel newQuestions = new Panel();
    newQuestions = question;
    container.Controls.Add(newQuestions);
}

但是当我点击添加问题按钮时,它并没有添加面板

虽然我无法从代码中看出问题可能出在问题参数上。还可以将 MVC 与控制器一起使用,它会更干净,而且 VS 会根据您的模型和控制器自动为您生成视图,我想这会在很长一段时间内为您节省时间 运行.