Solved

How To Dynamically Set Width to Panel Control?

Posted on 2002-06-17
6
229 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 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
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

732 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