c# - How to fill a transparent rectangle

Fill a rectangle using transparent PathGradientBrush
FillRectangleUsingTransparentPathGradientBrush.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(600, 250);
        Graphics g = Graphics.FromImage(bmp);

        g.Clear(Color.White);

        Brush drawingBrush = Brushes.DodgerBlue;
        Rectangle rect = new Rectangle(100, 75, 350, 50);
        g.FillRectangle(drawingBrush, rect);

        GraphicsPath gPath = new GraphicsPath();
        Rectangle rect2 = new Rectangle(0, 0, 100, 100);
        gPath.AddRectangle(rect2);

        PathGradientBrush pathGradientBrush = new PathGradientBrush(gPath);

        pathGradientBrush.CenterColor = Color.FromArgb(128, Color.Crimson);

        Color[] colors = { Color.FromArgb(128, Color.Linen) };
        pathGradientBrush.SurroundColors = colors;

        pathGradientBrush.WrapMode = WrapMode.Tile;

        Rectangle rect3 = new Rectangle(200, 50, 300, 150);

        g.FillRectangle(pathGradientBrush, rect3);

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

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

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>gdi+ 2D drawing transparent PathGradientBrush - how to fill a rectangle</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:MidnightBlue; font-style:italic;">
            How to fill a rectangle using transparent path gradient brush
            <br />System.Drawing.Drawing2D.PathGradientBrush
            <br />.NET GDI+ Graphics
        </h2>
        <hr width="600" align="left" color="DarkBlue" />
        <asp:Image
             ID="Image1"
             runat="server"
             />
        <br />
        <asp:Button 
            ID="Button1"
            runat="server"
            OnClick="Button1_Click"
            Text="Fill A Rectangle Using Transparent PathGradientBrush"
            Height="45"
            Font-Bold="true"
            ForeColor="DarkBlue"
            />
    </div>
    </form>
</body>
</html>
More asp.net examples