Wrox Programmer Forums
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 2nd, 2004, 11:42 AM
Registered User
 
Join Date: Jul 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to put a control inside a table cell?

'Does anyone know how to put a control- label,panel inside the table cell of table web control? Help!
I've seen an example but each time I drop a control in the cell, I lose it. Maybe there is a technique.

 
Old March 2nd, 2004, 11:46 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Where are you trying to do this? In the markup or code-behind?
 
Old March 2nd, 2004, 12:16 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Try typing text first like 'as' in the table cell, then drop the control in between the 'a' and 's'.

 
Old March 2nd, 2004, 05:31 PM
Registered User
 
Join Date: Jul 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by zach2004
 'Does anyone know how to put a control- label,panel inside the table cell of table web control? Help!
I've seen an example but each time I drop a control in the cell, I lose it. Maybe there is a technique.

In the code behind. I just want to drop a label control in the table cell and I don't know why it does'nt do it.

Thanks

 
Old March 2nd, 2004, 05:40 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

How do you "drop" a control in a table cell in the Code Behind? You seem to be mixing up two concepts here. The Design View allows for adding controls using drag and drop, while the Code Behind is used to add controls programmatically.

In Code Behind, you can simple add one control to another, using its Controls.Add method, like this:

MyTableCell.Controls.Add(LoadControl("/Controls/AnotherControl.ascx"));

or
Label newLabel = new Label();
newLabel.Text = "Bla Bla Bla";
MyTableCell.Controls.Add(newLabel);

In both cases, MyTableCell could be an HTML Table cell to which you can add other controls.

Does this help?

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old March 2nd, 2004, 06:03 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Ah... perhaps you mean in the markup. I failed to provide that as the third option.

To add a label control in the markup (HTML view) of your web form (or user control) you simply type the following inside the cell's <td> and </td> tag:

<asp:label runat="server" id="myLabel" />

You cannot drag-and-drop from the toolbar to the markup (or code-behind as noted by Imar).

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old March 2nd, 2004, 06:49 PM
Registered User
 
Join Date: Jul 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by zach2004
 'Does anyone know how to put a control- label,panel inside the table cell of table web control? Help!
I've seen an example but each time I drop a control in the cell, I lose it. Maybe there is a technique.

I mean it should be in the design. I'm sorry. The example I saw which was already the solution and in design mode -if I drag the table on the edge all the controls in the table cells are binded that they move also with the table. So my beginner's question then is can I drag a label control in a table cell in design mode -not HTML or code behind methods although both are possible. Thanks!

 
Old March 8th, 2004, 03:28 PM
Registered User
 
Join Date: Jul 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by zach2004
 'Does anyone know how to put a control- label,panel inside the table cell of table web control? Help!
I've seen an example but each time I drop a control in the cell, I lose it. Maybe there is a technique.

I undestood this pretty well now.Thanks!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Quick question put image in table cell user0b PHP How-To 0 June 26th, 2008 10:56 PM
How to put a button control in a GridView control ryan.webb ASP.NET 2.0 Basics 2 December 28th, 2007 05:26 AM
Add User Control to table cell in another UserCont veeruu ASP.NET 2.0 Professional 1 December 20th, 2006 06:22 AM
place anchor tag around bgImage inside cell?? mat41 HTML Code Clinic 4 January 26th, 2006 07:42 AM
How do I put this into a table? stacy Classic ASP Databases 3 February 3rd, 2004 07:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.