locked
How to create text box by the input of user RRS feed

  • Question

  • User1174443053 posted

    i need a complete tutorial about this

    here is the scenario

    i collect the user input for example, user input 10

    then the system will generate 10 text box in specific position and each text box have its own ID

    need is very urgent.... looking for solution

    please help me :(

    Sunday, March 17, 2013 9:41 PM

Answers

  • User260886948 posted

    Hi,

    I just create a simple example for you, please try to refer to:

    In the aspx:

    <body>
        <form id="form1" runat="server">
        <div>
    
            <asp:TextBox ID="Txtbox" runat="server"></asp:TextBox>
            <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
            <asp:Panel ID="Panel1" runat="server"></asp:Panel>
        </div>
        </form>
    </body>

    In the .cs:

    public partial class Default2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            int n=Convert.ToInt32(Txtbox.Text);
            TextBox[] txt = new TextBox[n];
            for (int i = 0; i < n; i++)
            {
                txt[i] = new TextBox();
                txt[i].ID = "this is the" + i + "textbox";
                Panel1.Controls.Add(txt[i]);
            }
        }
    }

    Hope it can help you.

    Best Regards,
    Amy Peng



     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 25, 2013 4:54 AM

All replies

  • User-993404089 posted

    Can you use jquery or other technology?

    Sunday, March 17, 2013 10:04 PM
  • User1174443053 posted

    just need the simplest solution for this

    after capture the input then generate the text box...

    i have done this in JAVA before...

    but i cant apply the knowledge from JAVA to here....

    i had done some research on google...

    but i dont understand and cant implement them into my system...

    Sunday, March 17, 2013 10:08 PM
  • User260886948 posted

    Hi,

    I just create a simple example for you, please try to refer to:

    In the aspx:

    <body>
        <form id="form1" runat="server">
        <div>
    
            <asp:TextBox ID="Txtbox" runat="server"></asp:TextBox>
            <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
            <asp:Panel ID="Panel1" runat="server"></asp:Panel>
        </div>
        </form>
    </body>

    In the .cs:

    public partial class Default2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            int n=Convert.ToInt32(Txtbox.Text);
            TextBox[] txt = new TextBox[n];
            for (int i = 0; i < n; i++)
            {
                txt[i] = new TextBox();
                txt[i].ID = "this is the" + i + "textbox";
                Panel1.Controls.Add(txt[i]);
            }
        }
    }

    Hope it can help you.

    Best Regards,
    Amy Peng



     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 25, 2013 4:54 AM