locked
Aspx dynamically created TextBox has no value RRS feed

  • Question

  • Hi!
     
    I'm creating a HtmlTable with a row and 2 cells. In one of these cells I add a TextBox. When I click on the 'create' button, the Text-Property of the TextBox is empty even though I entred a string. When I repeat that (type a string and click create) is works... so what to do?

    Thanks in advance!
    Kenshin
    trust is a weakness, betrayal is the hidden blade
    • Moved by Peter Ritchie Tuesday, October 14, 2008 3:04 PM asp.net question (Moved from Visual C# General to Off-Topic Posts (Do Not Post Here))
    Tuesday, October 14, 2008 12:13 PM

Answers

  • For questions and discussions relating to development for ASP.NET, please see http://forums.asp.net/

    http://www.peterRitchie.com/blog
    Tuesday, October 14, 2008 3:04 PM
  • Just saw that a post in my threads is unanswered ;)

    The solution was to handle the Page_Load event and create all elements in there, then showing the controls you really need.
    trust is a weakness, betrayal is the hidden blade
    • Marked as answer by NeoKenshinX Wednesday, February 25, 2009 1:55 PM
    Wednesday, February 25, 2009 1:55 PM

All replies

  • Neo, pls post the code over here to have a deeper look into the problem.
    Tuesday, October 14, 2008 1:32 PM
  •  
    this.DataFields.Rows.Clear();  
          foreach (string s in attributes)  
          {  
            HtmlTableRow row=new HtmlTableRow();  
            HtmlTableCell cell1=new HtmlTableCell();  
            HtmlTableCell cell2=new HtmlTableCell();  
     
            cell1.Style.Add(HtmlTextWriterStyle.Width, "131px");  
            cell2.Style.Add(HtmlTextWriterStyle.Width, "360px");  
     
            cell1.InnerText=s;  
            cell2.Controls.Add(new TextBox() { EnableViewState=false });  
            row.Cells.Add(cell1);  
            row.Cells.Add(cell2);  
            this.DataFields.Rows.Add(row);  
          } 

    this is the loop where the html is created

    thx hope this helps
    trust is a weakness, betrayal is the hidden blade
    Tuesday, October 14, 2008 2:34 PM
  • For questions and discussions relating to development for ASP.NET, please see http://forums.asp.net/

    http://www.peterRitchie.com/blog
    Tuesday, October 14, 2008 3:04 PM
  • Just saw that a post in my threads is unanswered ;)

    The solution was to handle the Page_Load event and create all elements in there, then showing the controls you really need.
    trust is a weakness, betrayal is the hidden blade
    • Marked as answer by NeoKenshinX Wednesday, February 25, 2009 1:55 PM
    Wednesday, February 25, 2009 1:55 PM