asp.net - How to change a Panel height programmatically

Panel height
Panel is an asp.net web server control. panel web server control is mainly used for host other controls. it acts as like a container for other controls and html elements. panel server controls built in Height property allow us to set or change its height programmatically at run time.

panel Height property get or set the height of panel server control. this property value type is System.Web.UI.WebControls.Unit. this property default value is Empty. the 'Unit' represents the height of panel. we can simply input a numeric value for panel Height property.

the following asp.net c# example code demonstrate us how can we assign panel web server control's height dynamically at run time in an asp.net application.
PanelHeight.aspx

<%@ Page Language="C#" %>

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        Panel1.Height = 150;

    }
    protected void Button2_Click(object sender, System.EventArgs e)
    {
        Panel1.Height = 200;
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to set, change Panel height programmatically</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Navy; font-style:italic;">Panel Example: Change Height</h2>
        <asp:Panel 
             ID="Panel1"
             runat="server"
             Height="100"
             Width="350"
             HorizontalAlign="Center"
             ForeColor="HotPink"
             BackColor="Azure"
             BorderColor="SkyBlue"
             BorderWidth="2"
             Font-Size="X-Large"
             Font-Bold="true"
             >
             <br />
             Change Height
        </asp:Panel>
        <br /><br />
        <asp:Button 
             ID="Button1" 
             runat="server"
             ForeColor="SaddleBrown"
             Text="Panel Height 150"
             Height="45"
             OnClick="Button1_Click"
             Font-Bold="true"
             />
        <asp:Button 
             ID="Button2" 
             runat="server"
             ForeColor="SaddleBrown"
             Text="Panel Height 200"
             Height="45"
             OnClick="Button2_Click"
             Font-Bold="true"
             />
    </div>
    </form>
</body>
</html>
More asp.net examples