ASP.Net add controls to panel - align horizontally

Posted on 2013-06-10
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);

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


Question by:JElster
  • 2
LVL 14

Accepted Solution

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);




Open in new window

LVL 25

Expert Comment

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?

Author Comment

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

Author Closing Comment

ID: 39238647
that worked

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I have developed many web applications with asp & and to add and use a dropdownlist was always a very simple task, but with the new, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

867 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now