?
Solved

How To Dynamically Set Width to Panel Control?

Posted on 2002-06-17
6
Medium Priority
?
246 Views
Last Modified: 2010-04-14
Hi All,

I have an ASP .Net webform, where I have a Panel control.

I am dynamically creating HyperLink controls, and I am binding them to the Panel control.

My problem is setting the width of the Panel control.  If the text of a Hyperlink control is short enough where it leaves room for the next Hyperlink control, the next one fills on the same line.

At the same time, if the text of a HyperLink control goes beyond the width of the Panel control it will split into two lines.

For example, say I have three Hyperlink controls.  The first one's text is Setup, and the second's text is Transaction, and the third's text is Post Transaction.

If I make the width of the Panel control wide enough to hold the third Hyperlink's text "Post Transaction", the first line will read "Setup Transaction", instead of "Setup", and the second line being "Transaction".

I cannot find a property in the Panel control that will force objects to list one at a time like a ListView, Listbox, etc.

I've been through capturing the width of the Hyperlink controls and trying to set the width of the Panel control by those values, but nothing works, due to the nature of the length of the text values.

I've set the Wrap property to True, because False keeps all object on the same line.

I've even added VbCrLf at the end of the text value of the Hyperlink controls when creating and binding them, but it doesn't help at all.

Does anyone have any ideas?

Thanks

RichW
0
Comment
Question by:RichW
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 22

Accepted Solution

by:
CJ_S earned 400 total points
ID: 7084194
instead of vbCrLf try "<br>"

....your line ... & "<br>"

CJ
0
 
LVL 23

Expert Comment

by:naveenkohli
ID: 7084388
Depending on client browser, Panl control emits <div> or <table> tag.
You best bet would be to eith add Panl control inside the Panel control for eacj Hyperlink control. Or you can add a lieral control after each Hyperlink control. And text of literal control will be set to "<br>"
0
 

Expert Comment

by:edyang75
ID: 7086889
I'd rather use a Table control to achieve your purpose; I'll put each link in a new row.

Reason: Table control renders as standard HTML TABLE element ; if you do not set its (and the TDs') width to a fixed value, its width will grow as needed.
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 4

Author Comment

by:RichW
ID: 7087857
Hi All,

I figured the problem out on my own, but the site went down yesterday, and I couldn't delete the question.

My answer is to place this line right after I add the HyperLink controls to the Panel control in my class:

frm.Panel1.Controls.Add(New LiteralControl("<br>"))

Since CJ_S was the closest to this answer I am awarding the points, but thanks to everyone who responded!
RichW
0
 
LVL 4

Author Comment

by:RichW
ID: 7087882
I just realized that naveenkohli gave the answer as well.

naveenkohli, look for a Points For naveenkohli.  I will give you 50 points.

Thanks
RichW
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 7087959
Thanks!

CJ
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

752 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