Solved

How To Dynamically Set Width to Panel Control?

Posted on 2002-06-17
6
211 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
6 Comments
 
LVL 22

Accepted Solution

by:
CJ_S earned 100 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 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

23 Experts available now in Live!

Get 1:1 Help Now