Solved

How To Dynamically Set Width to Panel Control?

Posted on 2002-06-17
6
225 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
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

685 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