Reputation: 3279
I've a table in my ASP.NET app, and add rows dynamically to it, each row has some cells each including a textbox, I generate everything dynamically, for instance:
tc = new TableCell();
TextBox t_total = new TextBox();
t_total.ID = "txtTotal" + dt.Rows[i]["Id"].ToString();
tc.Controls.Add(t_total);
tr.Cells.Add(tc);
I set an ID for my textbox, then I use this ID to access this object in a JavaScript function. How can I change this ID in my JavaScript function? for instance my textbox ID is set to "txtTotal1000" initially, then I'm going to change its ID to "txtTotal2000" in my JavaScript function so that I can access it using this new ID, how can I do so?
Upvotes: 0
Views: 919
Reputation: 541
You can use jQuery for that
$("#txtTotal1000").attr('id','txtTotal2000');
This will change the id of the element.
Upvotes: 1