468,771 Members | 1,974 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,771 developers. It's quick & easy.

Working with controls inside of a Server table.

I have a control inside of an asp:Table control. Once I place it in
there, I can't seem to edit it any more (Double click to add events,
drag to reposition, etc...). If I use an HTML table, no problem. Is
there any way around this. I have tried grid layout as well as flow
layout. Sample of the code.

<asp:Table id="Table1" runat="server" Width="512px" Height="344px"
BorderColor="Black" BorderStyle="Solid" BorderWidth="1px"
GridLines="Both">
<asp:TableRow>
<asp:TableCell>
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
</asp:TableCell>
<asp:TableCell></asp:TableCell>
</asp:TableRow>
</asp:Table>
Nov 18 '05 #1
2 1538
Scott,
You've discovered the Page's control hierarchy. I invite you to turn
Trace on to look at the control hierarchy for yourself. When you put server
controls on a page, the designer will automatically generate event handlers
for you. The textbox here is not a child of the page but a child of another
server control (Table), which is a child of the page. The table is in the
Page's Controls collection, but the textbox is in the Table's Controls
collection. To get to the TextBox, consider the following sample code:

//In Page_Load or Init
TextBox txt = (TextBox)tbl.FindControl("txt");
Trace.Write(txt.ID);
txt.TextChanged+=new EventHandler(txt_TextChanged);
private void txt_TextChanged(object sender, EventArgs e)
{
Trace.Warn("Text changed");
}

So since the textbox is inside another server control, it is not a direct
child of the Page, so the Page designer will not act on it.

Best regards,
Jeffrey Palermo

"Scott Kelley" <j_********@yahoo.com> wrote in message
news:49**************************@posting.google.c om...
I have a control inside of an asp:Table control. Once I place it in
there, I can't seem to edit it any more (Double click to add events,
drag to reposition, etc...). If I use an HTML table, no problem. Is
there any way around this. I have tried grid layout as well as flow
layout. Sample of the code.

<asp:Table id="Table1" runat="server" Width="512px" Height="344px"
BorderColor="Black" BorderStyle="Solid" BorderWidth="1px"
GridLines="Both">
<asp:TableRow>
<asp:TableCell>
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
</asp:TableCell>
<asp:TableCell></asp:TableCell>
</asp:TableRow>
</asp:Table>

Nov 18 '05 #2
May I assume then that there is no way around this? Controls that are
contained in other controls are just not workable in Visual
Studio.NET. I remember working in VB 5 and 6 and even if a control
was contained in another control, there was still a way to work with
it (click to create functions, drag and position, etc...). Makes me
rethink designing things this way if I can't work with controls in the
GUI editor. Thanks for the info.

Scott.
Scott,
You've discovered the Page's control hierarchy. I invite you to turn
Trace on to look at the control hierarchy for yourself. When you put server
controls on a page, the designer will automatically generate event handlers
for you. The textbox here is not a child of the page but a child of another
server control (Table), which is a child of the page. The table is in the
Page's Controls collection, but the textbox is in the Table's Controls
collection. To get to the TextBox, consider the following sample code:

//In Page_Load or Init
TextBox txt = (TextBox)tbl.FindControl("txt");
Trace.Write(txt.ID);
txt.TextChanged+=new EventHandler(txt_TextChanged);
private void txt_TextChanged(object sender, EventArgs e)
{
Trace.Warn("Text changed");
}

So since the textbox is inside another server control, it is not a direct
child of the Page, so the Page designer will not act on it.

Best regards,
Jeffrey Palermo

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Sacha Korell | last post: by
reply views Thread by aeshtry | last post: by
1 post views Thread by photo | last post: by
1 post views Thread by Eric | last post: by
reply views Thread by Przemek | last post: by
15 posts views Thread by Arpan | last post: by
5 posts views Thread by tshad | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.