Ask a Question related to ASP.NET General, Design and Development.
-
David Whitney #1
Dynamic HttpTableRow not rendering cell content...
All:
I have a control that renders a table. As the table is rendered, each
row in the table is constructed by creating a run-time (dynamic)
object that is derived from an HtmlTableRow. The row has three
HtmlTableCell objects, and each cell contains a single control added
to the HtmlTableCell's Controls collection. The basic table renders
correctly, but the controls within the HtmlTableCell objects do not;
the cells are just empty. (Just <TD></TD> tags).
I add the controls to each cell in my derived class constructor, and
that code fires in the debugger. The controls just don't render.
I'm sure there is a very basic problem I'm overlooking, but I'm
stymied as to what it is.
I'd greatly appreciate any thoughts.
David
ps Please reply to group; email in message is long since dead.
David Whitney Guest
-
Dynamic content and page rendering
Hi there, got a bit of a problem that's not easy to explain. I've got a site written in classic .asp, with bits and bobs of JavaScript, including... -
possible to target dynamic content to a table cell?
I'm in proof of concept mode. I've set up a small table with two rows and two columns. Column 1 shows a thumbnail image in each cell. Column 2... -
Cell Rendering with click event
I have a data grid that is a component for another page. In one of the columns in the data grid I am providing a check box. The plan is for the... -
Cell Rendering / Change Text
I have a data grid that is using cellrendering in on of the columns to provide a check box. When I check the box I would like to be able to change... -
Rendering design-time content on a web UserControl
I created a web user control and would like to add the ability for it to contain design-time rendering capabilities. So that, during development,... -
Louis Dascoulias #2
Re: Dynamic HttpTableRow not rendering cell content...
David,
Did you override the render method in the class that derives from
HtmlTableRow? Something like this:
protected override void Render(HtmlTextWriter writer)
{
writer.Write(this.Text);
}
You didn't provide any code so I'm asking the obvious.
Louis Dascoulias, AWS
"David Whitney" <intrepid_dw@hotmail.com> wrote in message
news:63563b00.0307170356.7e1ae677@posting.google.c om...> All:
>
> I have a control that renders a table. As the table is rendered, each
> row in the table is constructed by creating a run-time (dynamic)
> object that is derived from an HtmlTableRow. The row has three
> HtmlTableCell objects, and each cell contains a single control added
> to the HtmlTableCell's Controls collection. The basic table renders
> correctly, but the controls within the HtmlTableCell objects do not;
> the cells are just empty. (Just <TD></TD> tags).
>
> I add the controls to each cell in my derived class constructor, and
> that code fires in the debugger. The controls just don't render.
>
> I'm sure there is a very basic problem I'm overlooking, but I'm
> stymied as to what it is.
>
> I'd greatly appreciate any thoughts.
>
> David
>
> ps Please reply to group; email in message is long since dead.
Louis Dascoulias Guest
-
David Whitney #3
Re: Dynamic HttpTableRow not rendering cell content...
The short answer is no, I didn't, but here's why I didn't...
I presumed, probably incorrectly, that each element still knows how to
render itself, and that rendering a table row would be a matter of
rendering a cell, then its contents, etc, then the next cell, its
contents, etc... which would be part of its default behavior.
The code is essentially like this - note this is just scratched out
from memory - I'm away from my source at the moment.
public void MyDerivedHtmlTableRow(string somevalue)
{
HtmlTableCell hc = new HtmlTableCell();
HtmlInputBox ib = new HtmlInputBox();
ib.Text=somevalue;
hc.Controls.Add(ib);
//... add two other cells/controls similarly
this.Cells.Add(hc);
}
The calling class - a control - uses it like this:
public void AddTableRow()
{
for (x=1;x<=10;x++)
table.Rows.AddAt(number,
new MyDerivedTableRow(System.Convert.ToString(x))));
}
Since the *rows* rendered, but just not their contents, it seemed I
didn't need to implement custom rendering; the controls on each table
cell were not being rendered. If I'm just missing the boat on where to
do some rendering overrides, that's cool, I'm just trying to figure
out the right place...and a bit of where I might be confused..or is it
something as simple as
protected override void Render(HtmlTextWriter writer)
{
writer.Write(<TR>);
//custom render the first cell, and its one child control??
//custom render the second cell??
writer.Write(</TR>);
//or
//call an existing rendering method on the cell and its child
control??
}
Thoughts? (And thanks for your help, too!)
-David
"Louis Dascoulias" <louisd@automark.net> wrote in message news:<e1BTwtFTDHA.2152@TK2MSFTNGP12.phx.gbl>...> David,
> Did you override the render method in the class that derives from
> HtmlTableRow? Something like this:
> protected override void Render(HtmlTextWriter writer)
> {
> writer.Write(this.Text);
> }
>
> You didn't provide any code so I'm asking the obvious.
>
> Louis Dascoulias, AWS
>
> "David Whitney" <intrepid_dw@hotmail.com> wrote in message
> news:63563b00.0307170356.7e1ae677@posting.google.c om...> > All:
> >
> > I have a control that renders a table. As the table is rendered, each
> > row in the table is constructed by creating a run-time (dynamic)
> > object that is derived from an HtmlTableRow. The row has three
> > HtmlTableCell objects, and each cell contains a single control added
> > to the HtmlTableCell's Controls collection. The basic table renders
> > correctly, but the controls within the HtmlTableCell objects do not;
> > the cells are just empty. (Just <TD></TD> tags).
> >
> > I add the controls to each cell in my derived class constructor, and
> > that code fires in the debugger. The controls just don't render.
> >
> > I'm sure there is a very basic problem I'm overlooking, but I'm
> > stymied as to what it is.
> >
> > I'd greatly appreciate any thoughts.
> >
> > David
> >
> > ps Please reply to group; email in message is long since dead.David Whitney Guest
-
Louis Dascoulias #4
Re: Dynamic HttpTableRow not rendering cell content...
David,
It finally occured to me: you must assign an ID to the child control.
Nothing will automatically assign one to the control.
Previous thoughts:
You may need to call EnsureChildControls at some point after adding
the textboxes to the cell since the textboxes aren't a component/property
of the cells.
I played around with createing 'table-maker' controls in VB.Net a while back
so I can provide some code if needed..
Louis Dascoulias, AWS
"David Whitney" <intrepid_dw@hotmail.com> wrote in message
news:63563b00.0307170959.607d080b@posting.google.c om...news:<e1BTwtFTDHA.2152@TK2MSFTNGP12.phx.gbl>...> The short answer is no, I didn't, but here's why I didn't...
>
> I presumed, probably incorrectly, that each element still knows how to
> render itself, and that rendering a table row would be a matter of
> rendering a cell, then its contents, etc, then the next cell, its
> contents, etc... which would be part of its default behavior.
>
> The code is essentially like this - note this is just scratched out
> from memory - I'm away from my source at the moment.
>
> public void MyDerivedHtmlTableRow(string somevalue)
> {
> HtmlTableCell hc = new HtmlTableCell();
> HtmlInputBox ib = new HtmlInputBox();
> ib.Text=somevalue;
>
> hc.Controls.Add(ib);
>
> //... add two other cells/controls similarly
>
> this.Cells.Add(hc);
> }
>
> The calling class - a control - uses it like this:
>
> public void AddTableRow()
> {
> for (x=1;x<=10;x++)
> table.Rows.AddAt(number,
> new MyDerivedTableRow(System.Convert.ToString(x))));
> }
>
> Since the *rows* rendered, but just not their contents, it seemed I
> didn't need to implement custom rendering; the controls on each table
> cell were not being rendered. If I'm just missing the boat on where to
> do some rendering overrides, that's cool, I'm just trying to figure
> out the right place...and a bit of where I might be confused..or is it
> something as simple as
>
> protected override void Render(HtmlTextWriter writer)
> {
> writer.Write(<TR>);
> //custom render the first cell, and its one child control??
> //custom render the second cell??
> writer.Write(</TR>);
>
> //or
>
> //call an existing rendering method on the cell and its child
> control??
> }
>
> Thoughts? (And thanks for your help, too!)
>
> -David
>
>
>
> "Louis Dascoulias" <louisd@automark.net> wrote in message> > David,
> > Did you override the render method in the class that derives from
> > HtmlTableRow? Something like this:
> > protected override void Render(HtmlTextWriter writer)
> > {
> > writer.Write(this.Text);
> > }
> >
> > You didn't provide any code so I'm asking the obvious.
> >
> > Louis Dascoulias, AWS
> >
> > "David Whitney" <intrepid_dw@hotmail.com> wrote in message
> > news:63563b00.0307170356.7e1ae677@posting.google.c om...> > > All:
> > >
> > > I have a control that renders a table. As the table is rendered, each
> > > row in the table is constructed by creating a run-time (dynamic)
> > > object that is derived from an HtmlTableRow. The row has three
> > > HtmlTableCell objects, and each cell contains a single control added
> > > to the HtmlTableCell's Controls collection. The basic table renders
> > > correctly, but the controls within the HtmlTableCell objects do not;
> > > the cells are just empty. (Just <TD></TD> tags).
> > >
> > > I add the controls to each cell in my derived class constructor, and
> > > that code fires in the debugger. The controls just don't render.
> > >
> > > I'm sure there is a very basic problem I'm overlooking, but I'm
> > > stymied as to what it is.
> > >
> > > I'd greatly appreciate any thoughts.
> > >
> > > David
> > >
> > > ps Please reply to group; email in message is long since dead.
Louis Dascoulias Guest



Reply With Quote

