Nu har jeg løst mit problem, men med ren ASP.NET.
Her er min kode, hvis andre skulle lave noget lignende:
<%@ Page Language="vb" AutoEventWireup="false" ContentType="image/gif"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.data.sqlclient" %>
<%@ Import Namespace = "System.Drawing" %>
<%@ Import Namespace = "System.Drawing.Imaging" %>
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim objBitmap As Bitmap
Dim objGraphics As Graphics
objBitmap = New Bitmap(5050, 100)
objGraphics = Graphics.FromImage(objBitmap)
objGraphics.DrawLine(New Pen(Color.Red), 0, 25, 0, 75)
objGraphics.DrawString("År 2500 f.kr.", New Font("Times new roman", 10), Brushes.Red, 0, 60)
objGraphics.DrawLine(New Pen(Color.Red), 2500, 25, 2500, 75)
objGraphics.DrawString("År 0", New Font("Times new roman", 10), Brushes.Red, 2500, 60)
objGraphics.DrawLine(New Pen(Color.Red), 5000, 25, 5000, 75)
objGraphics.DrawString("År 2500", New Font("Times new roman", 10), Brushes.Red, 5000, 60)
objGraphics.DrawLine(New Pen(Color.Red), 0, 50, 5000, 50)
Dim connString As String = System.Configuration.ConfigurationManager.ConnectionStrings("Forum_dataConnectionString").ConnectionString
Dim selectCmd As String
selectCmd = "SELECT * FROM TimeLine ORDER BY Year DESC"
Dim connect As SqlConnection
connect = New SqlConnection(connString)
Dim cmd As SqlCommand = New SqlCommand(selectCmd, connect)
Dim i As Integer = 0
Try
connect.Open()
Dim reader As SqlDataReader = cmd.ExecuteReader()
Dim BC As String
While reader.Read
BC = reader("BC").ToString
If BC.ToLower = "true" Then
If i Mod 2 = 0 Then
Dim Year As Integer = reader("Year")
objGraphics.DrawLine(New Pen(Color.Red), 2500 - Year, 50, 2500 - Year, 85)
objGraphics.DrawString("År " + Year.ToString + " f.kr.", New Font("Times new roman", 10), Brushes.Red, 2500 - (Year + 1), 60)
objGraphics.DrawString(reader("Description"), New Font("Times new roman", 10), Brushes.Red, 2500 - (Year + 1), 75)
Else
Dim Year As Integer = reader("Year")
objGraphics.DrawLine(New Pen(Color.Red), 2500 - Year, 50, 2500 - Year, 10)
objGraphics.DrawString("År " + Year.ToString + " f.kr.", New Font("Times new roman", 10), Brushes.Red, 2500 - (Year + 1), 10)
objGraphics.DrawString(reader("Description"), New Font("Times new roman", 10), Brushes.Red, 2500 - (Year + 1), 25)
End If
Else
If i Mod 2 = 0 Then
Dim Year As Integer = reader("Year")
objGraphics.DrawLine(New Pen(Color.Red), Year + 2500, 50, Year + 2500, 85)
objGraphics.DrawString("År " + Year.ToString, New Font("Times new roman", 10), Brushes.Red, Year + 1 + 2500, 60)
objGraphics.DrawString(reader("Description"), New Font("Times new roman", 10), Brushes.Red, Year + 1 + 2500, 75)
Else
Dim Year As Integer = reader("Year")
objGraphics.DrawLine(New Pen(Color.Red), Year + 2500, 50, Year + 2500, 10)
objGraphics.DrawString("År " + Year.ToString, New Font("Times new roman", 10), Brushes.Red, Year + 1 + 2500, 10)
objGraphics.DrawString(reader("Description"), New Font("Times new roman", 10), Brushes.Red, Year + 1 + 2500, 25)
End If
End If
i = i + 1
End While
Finally
connect.Close()
connect.Dispose()
End Try
objBitmap.Save(Response.OutputStream, ImageFormat.Gif)
objBitmap.Dispose()
objGraphics.Dispose()
End Sub
</script>
MVH/Jeppe
Indlæg senest redigeret d. 06.09.2009 13:39 af Bruger #13488