Connecting Tech Pros Worldwide Help | Site Map

problem in getting textbox id.

Newbie
 
Join Date: Apr 2009
Location: Vizag,India
Posts: 28
#1: May 5 '09
Hi boss,

In my page i am generating some text boxes dynamically on Button_click like this...


Expand|Select|Wrap|Line Numbers
  1. for (int i = 1; i <= cols; i++)
  2.         {
  3.             HtmlTableRow objRow = new HtmlTableRow();
  4.             HtmlTableCell objCell = new HtmlTableCell();
  5.             objCell.InnerHtml = "<td>ColumnName</td>" + 
  6. "<td><input id=\"txtColumnName"+i+"\" name=\"txtColumnName"+i+"\" runat=\"server\" type=\"text\" /></td>" + 
  7. "<td>ColumnWidth</td>" + "<td><input id=\"txtColumnWidth"+i+"\" name=\"txtColumnWidth"+i+"\" runat=\"server\" type=\"text\" /></td>";
  8.             objRow.Cells.Add(objCell);
  9.             objTbl.Rows.Add(objRow);
  10.         }
  11.         this.Controls.Add(objTbl);


but in another button_click I need to display the text entered in those text boxes , so i need to get the id's of those text boxes .
How can i get those textboxes ids.....can anybody give an idea...

Thanking you....
Newbie
 
Join Date: Apr 2009
Posts: 17
#2: May 5 '09

re: problem in getting textbox id.


I am also stuck with this concept.
particularly while assigning event handlers and calling event handlers back won't work.
Member
 
Join Date: Aug 2007
Location: Pakistan
Posts: 91
#3: May 5 '09

re: problem in getting textbox id.


First I think not sure that you cannot create server control like you are creating the textboxes.
Second what side i.e( in client script or server script ) you want to access the id.
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,066
#4: May 5 '09

re: problem in getting textbox id.


Quote:

Originally Posted by Hamayun Khan View Post

First I think not sure that you cannot create server control like you are creating the textboxes.
Second what side i.e( in client script or server script ) you want to access the id.

Vinod Allapu not actually creating Server Controls.
Vinod Allapu is dynamically creating HTML input elements and so the OP will naturally have a problem accessing these input elements in their server side code because HTML input elements are not server side controls.

Vinod Allapu,your other attempt at this problem is probably going to work better in the long run. Please take a look at your other thread.

You should probably do some more research into Templates, Templated Controls, and how to use templates with grid views. Also you should probably read up on how to use dynamic controls in ASP.NET also.
Reply