asp.net listbox auto height

asp.net listbox auto height
listbox-auto-height.aspx

<%@ Page Language="C#" AutoEventWireup="true"%>    
      
<!DOCTYPE html>
        
<script runat="server">  
    protected void Page_Load(object sender, EventArgs e)  
    {
        if (!Page.IsPostBack)
        {
            string[] birds = { 
                                 "Pilotbird",
                                 "Fernwren",
                                 "White-browed Scrubwren",
                                 "Weebill",
                                 "White-throated Gerygone",
                                 "Southern Whiteface",
                                 "Brown Thornbill",
                                 "Yellow-rumped Thornbill",
                                 "Grey-crowned Babbler"
                             };

            ListBox1.DataSource = birds;
            ListBox1.DataBind();
            ListBox1.Rows = ListBox1.Items.Count;
        }
    }
</script>        
        
<html xmlns="http://www.w3.org/1999/xhtml">        
<head id="Head1" runat="server">        
    <title>asp.net listbox auto height</title>  
</head>        
<body>        
    <form id="form1" runat="server">        
    <div>        
        <h2 style="color:MidnightBlue; font-style:italic;">        
            asp.net example - listbox auto height
        </h2>        
        <hr width="550" align="left" color="Gainsboro" />   
        <br />  
        <asp:ListBox  
            ID="ListBox1"  
            runat="server"  
            AutoPostBack="true"  
            Font-Size="X-Large"
            SelectionMode="Multiple"
            Width="350"
            Font-Names="Comic Sans MS"  
            >  
        </asp:ListBox>  
    </div>        
    </form>        
</body>        
</html>
More asp.net examples