Solved

ASP.Net add controls to panel - align horizontally

Posted on 2013-06-10
4
1,597 Views
Last Modified: 2013-06-11
I'm creating a control programmatically - added a panel then a toolbar and other controls.
But the controls alway render vertically - l've tried apply a css but doesn't seem to work
how can I render the control on the panel horizontally?

 Panel panel = new Panel();
            panel.HorizontalAlign = HorizontalAlign.Left;
            panel.Height = 30;

           
            btn = new  Button();
            btn.Text = "Add ";
            btn.Height = Unit.Pixel(30);
            btn.Width = Unit.Pixel(100);
         
panel.controls.add(btn)

       btn = new  Button();
            btn.Text = "Delete ";
            btn.Height = Unit.Pixel(30);
            btn.Width = Unit.Pixel(100);


panel.controls.add(btn)

etc....
0
Comment
Question by:JElster
  • 2
4 Comments
 
LVL 14

Accepted Solution

by:
dejaanbu earned 400 total points
ID: 39236774
consider adding a dynamic htmltable , and then add the buttons to the cells of table rows.
Table tbl = new Table();
TableRow tr = new TableRow();
TableCell tc = new TableCell();

btn = new  Button();
            btn.Text = "Add ";
            btn.Height = Unit.Pixel(30);
            btn.Width = Unit.Pixel(100);

tc.Controls.Add(btn);

tr.Controls.Add(tc);
tbl.Controls.Add(tr);
//etc..

panel.Controls.Add(tbl);

Open in new window

0
 
LVL 25

Expert Comment

by:Rouchie
ID: 39238434
Sorry but I disagree with that idea - tables are not meant for general control layout unless tabular data is required.

First make sure your panel is wide enough to allow controls to sit side-by-side.  I assume you've removed some code from your example for brevity, so the next job is to remove all CSS from the panel and buttons.

Can you post a screen grab after that if you still have problems?
0
 
LVL 1

Author Comment

by:JElster
ID: 39238629
Code is a simple as that... no CSS
buttons appear vertical on top of each other.
0
 
LVL 1

Author Closing Comment

by:JElster
ID: 39238647
that worked
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

823 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question