Solved

ASP.Net add controls to panel - align horizontally

Posted on 2013-06-10
4
1,535 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
Comment Utility
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
Comment Utility
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
Comment Utility
Code is a simple as that... no CSS
buttons appear vertical on top of each other.
0
 
LVL 1

Author Closing Comment

by:JElster
Comment Utility
that worked
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

771 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

12 Experts available now in Live!

Get 1:1 Help Now