problem in getting textbox id.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vinod allapu
    New Member
    • Apr 2009
    • 28

    problem in getting textbox id.

    Hi boss,

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


    Code:
    for (int i = 1; i <= cols; i++)
            {
                HtmlTableRow objRow = new HtmlTableRow();
                HtmlTableCell objCell = new HtmlTableCell();
                objCell.InnerHtml = "<td>ColumnName</td>" + 
    "<td><input id=\"txtColumnName"+i+"\" name=\"txtColumnName"+i+"\" runat=\"server\" type=\"text\" /></td>" + 
    "<td>ColumnWidth</td>" + "<td><input id=\"txtColumnWidth"+i+"\" name=\"txtColumnWidth"+i+"\" runat=\"server\" type=\"text\" /></td>";
                objRow.Cells.Add(objCell);
                objTbl.Rows.Add(objRow);
            }
            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....
    Last edited by Frinavale; May 5 '09, 02:42 PM. Reason: Added code tags. Please post code in [code] [/code] tags.
  • wastman
    New Member
    • Apr 2009
    • 17

    #2
    I am also stuck with this concept.
    particularly while assigning event handlers and calling event handlers back won't work.

    Comment

    • Hamayun Khan
      New Member
      • Aug 2007
      • 106

      #3
      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.

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Originally posted by Hamayun Khan
        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.

        Comment

        Working...