forum

Home / DeveloperSection / Forums / how to get values from dynamically generated text boxes?

how to get values from dynamically generated text boxes?

Manoj Bhatt 1730 29-Sep-2014

I am trying to get the values of text box which i generated dynamically on page load and cloned them using jquery....

 

every text box has a unique id in form of a matrix for eg textboxes of row one have ids textbox11,textbox12,textbox13,textbox14 etc for row two textbox21,textbox22,textbox23........ 

is there any way to get the values.. 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
public partial class product_entry : System.Web.UI.Page
{
    int count;
    protected void Page_Load(object sender, EventArgs e)
    {
        int i, j;
        for (i = 0; i < 1; i++)
        {
            TableRow tr = new TableRow();
            tr.Attributes.Add("class", "tabrow");
 
            for (j = 0; j <= 8; j++)
            {
                TableCell tc = new TableCell();
 
                if (j == 0)
                {
                    tc.Controls.Add(new LiteralControl("<Button class=remove type=button>-</button>"));
                }
                if (j == 1)
                {
                    tc.Attributes.Add("class", "sno");
                }
                if (j == 2 || j == 3 || j == 4 || j == 5 || j == 6 || j == 7 || j == 8)
                {
                    TextBox tb = new TextBox();
                    tb.Style["width"] = "98%";
                    tc.Controls.Add(tb);
                }
                tr.Controls.Add(tc);
            }
            Table1.Controls.Add(tr);
        }
    }
 
    protected void Button1_Click(object sender, EventArgs e)
    {
        Label2.Text = TextBox1.Text;
    for (int i = 1; i <= count; i++)
    {
        for (int j = 1; j <= 7; j++)
        {
            TextBox aa = (TextBox)Pnl.FindControl("textbox" + i + j);
            Response.Write(aa.Text);
        }
    }
    }
}

i want to fetch the values of hundreds of text boxes geerated using jquery by using the loop designed above is there any way to do that


Updated on 29-Sep-2014

Can you answer this question?


Answer

1 Answers

Liked By