Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6904669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:05:24+00:00 2026-05-27T08:05:24+00:00

I have a button to clone a textbox, which allow the user to type

  • 0

I have a button to clone a textbox, which allow the user to type in too

jquery

function generateRow() {
if (totalans == 9) {
    $('#<%= label2.ClientID %>').html('<b>Maximum of 10 answers per questions reached</b>');
}
else {
    totalans = totalans + 1; // same as totalans++;
     $("#ans").clone().attr({id: "ans_clone_" + totalans, name: "ans_clone_" + totalans}).prependTo("#ans2");
     // then you can loop through each input using the totalans variable.
}

Now, I have no idea on how to retrieve those textbox in codebehind c#.
As I want to store it inside the database.

I have got some help from someone here, but it still couldnt help me.

for(x=0; x<totalans; x++){ var tVal = $('#ans_clone_' + x).val(); //process }

im using vs2010, DotNet.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:05:24+00:00Added an answer on May 27, 2026 at 8:05 am

    Add HiddenField server control onto page and use it to store count of dynamically added textboxes. Then, on post back parse it’s value and fetch dynamically added textboxes values from Request.Params collection:

    function addAnswer() {
         var hfAnswers = $("#<%= hfDynamicAnswers.ClientID %>");
         var answers = parseInt(hfAnswers.val()) + 1;
         hfAnswers.val(answers);
    
         $("#<%= tbAnswer.ClientID %>").clone().attr({ name: "ans_clone_" + answers, id: "ans_clone_" + answers }).appendTo("#answersContainer");
    }
    
    <asp:HiddenField runat="server" ID="hfDynamicAnswers" Value="0" />
    <div id="answersContainer">
         <asp:TextBox runat="server" ID="tbAnswer" />
         <input type="button" value="Add Answer" onclick="addAnswer()" />
    </div>
    <asp:Button runat="server" ID="btnSubmit" Text="Submit" OnClick="btnSubmit_Click" />
    

    Code-behind:

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        var answers = int.Parse(hfDynamicAnswers.Value);
        for (int i = 1; i <= answers; i++)
        {
            var answer = Request.Params["ans_clone_" + i.ToString()];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a form which adds controls dynamically with user selecting the type
I have button, which fires an event, that deletes a record from the database.
I have a textbox and a button on a form. I wish to run
I have the following table <table id=invoice> <tr> <th>Quantity</th> <th>Item</th> <th><input type=button id=addnew name=addnew
I have a simple linearlayout with a textbox a button and a listview, I'm
I have created a User Control in my application that has a textbox and
I have the following html which displays 3 textboxes and an add button: <html
I have two forms, one with a button 'Add' which loads the second form
I'd like to have a TabNavigator component that has a close button for some
When designing a form I have the option of putting a close button at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.