asp.net - How to change Panel horizontal align programmatically

How to set, change Panel horizontal align programmatically
PanelHorizontalAlign.aspx
<%@ Page Language="C#" %>

<!DOCTYPE html>

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

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

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to set, change Panel horizontal align programmatically</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Navy; font-style:italic;">Panel Example: HorizontalAlign</h2>
        <asp:Panel 
             ID="Panel1"
             runat="server"
             Height="150"
             Width="400"
             BorderWidth="2"
             Font-Size="X-Large"
             Font-Bold="true"
             ForeColor="Olive"
             BackColor="Beige"
             BorderColor="DarkOliveGreen"
             >
             <br />
             HorizontalAlign
        </asp:Panel>
        <br /><br />
        <asp:Button 
             ID="Button1" 
             runat="server"
             ForeColor="SeaGreen"
             Text="Panel HorizontalAlign Right"
             Height="45"
             OnClick="Button1_Click"
             Font-Bold="true"
             />
        <asp:Button 
             ID="Button2" 
             runat="server"
             ForeColor="SeaGreen"
             Text="Panel HorizontalAlign Center"
             Height="45"
             OnClick="Button2_Click"
             Font-Bold="true"
             />
    </div>
    </form>
</body>
</html>








Related asp.net example