C# - How to draw a gradient text

Draw gradient text
DrawGradientText.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.GhostWhite);

        Rectangle rect = new Rectangle(0,0,500,250);
        
        LinearGradientBrush lgBrush = new LinearGradientBrush(rect,Color.DeepPink,Color.LawnGreen,LinearGradientMode.ForwardDiagonal);

        String stringToDraw = "ASP.NET";
        Font drawFont = new Font("Comic Sans MS", 75,FontStyle.Bold);
        PointF drawPoint = new PointF(50, 50);

        g.DrawString(stringToDraw, drawFont, lgBrush, drawPoint);

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

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

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>how to draw gradient text</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:MidnightBlue; font-style:italic;">
            How to draw gradient text string
            <br />System.Drawing.Drawing2D
            <br />GDI+ Graphics LinearGradientBrush
        </h2>
        <hr width="600" align="left" color="SkyBlue" />
        <asp:Image
             ID="Image1"
             runat="server"
             />
        <br />
        <asp:Button 
            ID="Button1"
            runat="server"
            OnClick="Button1_Click"
            Text="Draw Gradient Text"
            Height="45"
            Font-Bold="true"
            ForeColor="MidnightBlue"
            />
    </div>
    </form>
</body>
</html>
More asp.net examples