ASP.NET - How to draw a series of rectangles

Draw a series of rectangles
GraphicsDrawRectanglesMethod.aspx

<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Text" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<%@ Import Namespace="System.Drawing.Imaging" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        Bitmap bmp = new Bitmap(500,250);
        Graphics g = Graphics.FromImage(bmp);
        g.Clear(Color.DeepPink);

        Pen snowPen = new Pen(Color.Snow, 2);

        Rectangle rect1 = new Rectangle(5,5,50,100);
        Rectangle rect2 = new Rectangle(15,25,75,50);
        Rectangle rect3 = new Rectangle(100,50,300,150);
        Rectangle rect4 = new Rectangle(150,100,50,25);
        
        Rectangle[] rectangleArray = { rect1,rect2,rect3,rect4 };
        
        g.DrawRectangles(snowPen,rectangleArray);
        //g.DrawRectangles(Pen, Rectangle());

        String path = Server.MapPath("~/Image/DrawRectangles.jpg");
        bmp.Save(path,ImageFormat.Jpeg);

        Image1.ImageUrl = "~/Image/DrawRectangles.jpg";
        g.Dispose();
        bmp.Dispose();
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>asp.net graphics (GDI+) - how to draw a series of rectangles</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:DodgerBlue; font-style:italic;">
            How to draw a series of rectangles specified by
            <br />Rectangle structures in asp.net graphics (GDI+)
            <br />Graphics.DrawRectangles Method (Pen, Rectangle())
        </h2>
        <hr width="500" align="left" color="DeepSkyBlue" />
        <asp:Image
             ID="Image1"
             runat="server"
             />
        <br />
        <asp:Button 
            ID="Button1"
            runat="server"
            OnClick="Button1_Click"
            Text="DrawRectangles"
            Height="45"
            Font-Bold="true"
            ForeColor="DodgerBlue"
            />
    </div>
    </form>
</body>
</html>
More asp.net examples