Create dynamic controls one-by-one on button click

Dec 9, 2010 at 10:59 AM

Hi,

I have a form with one textbox(txtCaption), one dropdown(controlType) and one button. I am using textbox for dynamic control's caption, dropdown for control types and button for creating dynamic controls based on selected criteria.

<table>
                        <tr>
                            <td>
                                <asp:Label ID="Label1" runat="server" Text="Caption:"></asp:Label>
                            </td>
                            <td>
                                <asp:TextBox ID="txtCaption" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="Label2" runat="server" Text="Control Type:"></asp:Label>
                            </td>
                            <td>
                                <asp:DropDownList ID="controlType" runat="server">
                                    <asp:ListItem Value="TextBox">TextBox</asp:ListItem>
                                    <asp:ListItem Value="DropDownList">DropDownList</asp:ListItem>
                                    <asp:ListItem Value="CheckBox">CheckBox</asp:ListItem>
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                &nbsp;
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td align="center" colspan="2" valign="top">
                                <input type="button" value="Add Field" />
                            </td>
                        </tr>
                    </table>

  I want to create dynamci control in another <div> based on selected controlType and caption using MvcDynamciForm. Please give me any sample project.

 

Sujeet