Wednesday, March 28, 2012

TableCell.Text property overwrites dynamic control

If I add a hidden input control to a tablecell and then set the cell's text
property, the hidden control is not output. If I set the text first, then
the hidden control is output but the text is not. No errors are generated.
I can make it work by adding a literal control instead of using the text
property, but why doesn't the "simple" method work?

Dim tCell As TableCell = New TableCell
Dim thidden As HtmlInputHidden = New HtmlInputHidden
thidden.ID = "h1"
thidden.Value = "hidden text"
tCell.Controls.Add(thidden)
tCell.Text = "visible text"
tRow.Cells.Add(tCell)Maybe add the text as a literal?

Joe

"Bob Voss" <bvoss@.Xspam.tsts.com> wrote in message
news:%23iH0xNNxDHA.2408@.tk2msftngp13.phx.gbl...
> If I add a hidden input control to a tablecell and then set the cell's
text
> property, the hidden control is not output. If I set the text first, then
> the hidden control is output but the text is not. No errors are
generated.
> I can make it work by adding a literal control instead of using the text
> property, but why doesn't the "simple" method work?
> Dim tCell As TableCell = New TableCell
> Dim thidden As HtmlInputHidden = New HtmlInputHidden
> thidden.ID = "h1"
> thidden.Value = "hidden text"
> tCell.Controls.Add(thidden)
> tCell.Text = "visible text"
> tRow.Cells.Add(tCell)

0 comments:

Post a Comment