By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,931 Members | 1,599 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,931 IT Pros & Developers. It's quick & easy.

Working with controls inside of a Server table.

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.