Results 1 to 10 of 10

Thread: adding a control to a tableCell deletes all the text?

  1. #1

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Question adding a control to a tableCell deletes all the text?

    Umm I;m creating a table at runtime. I'm creating TableCells, it's been working fine till now. I have some stuff added to the TableCell.Text and it worked fine, but now that I'm also adding a linkButton control to the cell, all the text disappears and only the link button shows up.

    What's wrong with what I'm doing? how can I preserve the text in the tableCell when I add the linkButton control to it?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  2. #2

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    anyone knows what I'm talking about?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  3. #3
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Without seeing your code, its hard to tell where your going wrong. I just whipped this up and it works fine:

    Code:
    HtmlTable t = new HtmlTable();
    HtmlTableRow r = new HtmlTableRow();
    HtmlTableCell c = new HtmlTableCell();
    LiteralControl l = new LiteralControl("Name: ");
    c.Controls.Add(l);
    LinkButton lnk = new LinkButton();
    lnk.Text = "Click Me";
    c.Controls.Add(lnk);
    r.Cells.Add(c);
    t.Rows.Add(r);
    FindControl("Form1").Controls.Add(t);

  4. #4

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    umm well yeah I didnt add the text with a literal control I just set the .TEXT property, anything wrong with that?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  5. #5
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Originally posted by MrPolite
    umm well yeah I didnt add the text with a literal control I just set the .TEXT property, anything wrong with that?
    Yes, it isn't working for you....

  6. #6
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Originally posted by MrPolite
    umm well yeah I didnt add the text with a literal control I just set the .TEXT property, anything wrong with that?
    I agree with hellswraith...

  7. #7

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    well thanks hellswraith I didn't know that it wasn't working...

    what's the purpose of the Text property of a table cell then?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  8. #8
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    To put text in it when you are not adding controls to it.

  9. #9
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    MSDN Library says:
    Remarks
    Use the Text property to specify or determine the text contents of the cell. This property is commonly used to programmatically update the contents of a cell.

    Note Setting the Text property will clear any other controls contained in the TableCell.
    CAUTION This control can be used to display user input, which might include malicious client script. Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. ASP.NET provides an input request validation feature to block script and HTML in user input. Validation server controls are also provided to assess user input. For more information, see Validation Server Controls.

  10. #10

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    thanks alot, makes sense now, hehe
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width