Autoresize ASP.NET panel having a dynamic collection of overflowing buttons
basically, inside a client control , i'm calling a query to fetch some
data from a table and based on the output, i create buttons and add them
from code behind to an ASP:Panel
The buttons have a CSS to flow to left one next to the other instead of
displaying them as a block under each other.
CSS
.button_red2
{ background:url('../../images/button_red_left.gif') no-repeat left top;
display:block; font-size:12px; font-weight:bold; line-height:16px;
height:21px; padding-left:9px;
padding-top:0px; margin-bottom :2px; text-decoration:none;
border-style:none; color:White; width:auto; overflow:visible ;
float:left;}
.button_red2 span
{ background:transparent url('../../images/button_red.gif') no-repeat
top right;
padding:3px 10px 2px 0px; border-style:none; display:block ;}
in codebehind
Dim locationdt =
sqlDMLhelper.ExecuteQueryDT(String.Format("select distinct
City from {2}{1}{2} where Staff_FK='{0}' order by City
ASC", staffID, "EUS-Customer", ControlChars.Quote), cerr)
If Not locationdt.Rows.Count = 0 Then
For i = 0 To locationdt.Rows.Count - 1
Dim Sitename = locationdt.Rows(i).Item(0)
Dim thebutton = New LiteralControl(" <button
ID='Button'" & i & " runat='server'
class='button_red2' onclick='ClickedSite(""" &
Sitename & """);' type='button'> <span> " &
Sitename & "</span> </button> ")
DrilldownPanel.Controls.Add(thebutton)
Next
End If
in aspx
<h1> Drill Down Per Site </h1>
<div style="display:block; padding-top: 5px; " ></div>
<asp:Panel ID="DrilldownPanel" runat="server" Height="21" >
</asp:Panel>
I can safely specify height 21 as i will always have at least one button.
The container itself is set to 600 px width.
i'm wondering if there is a way to dynamically set the height value of the
"DrilDownPanel" given that
I don't know how many locations i will have (at least 1),
how long the names of the locations will be and at what point they thus
start overflowing to the next line.
What tools are available to loop through the collection items of that
panel to see how many "lines" i've got and thus adjust the height
dynamically before the rendering starts.
..or not possible?
tnxs a lot
No comments:
Post a Comment