No Image

  • Thread starter Web Team @ Borough of Poole
  • Start date
W

Web Team @ Borough of Poole

Hi All,

I have borrowed some code from here:
http://www.codeproject.com/aspnet/aspnet_web_graphics.asp

This works as expected when I use in-line code, but when I moved it to
code-behind, it stops working. The image does not appear, no
errors...all I get is a blank HTML page:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html;
charset=windows-1252"></HEAD>
<BODY></BODY></HTML>

Note the content type of text/html.


Heres my code-behind:

Imports System.Drawing
Imports System.Drawing.Text
Imports System.Drawing.Imaging
Imports System.Drawing.Drawing2D

Public Class image
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

'NOTE: The following placeholder declaration is required by the Web
Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Response.Clear()
Dim height As Integer = 100
Dim width As Integer = 200
Dim r As New Random
Dim x As Integer = r.Next(75)

Dim bmp As New Bitmap(width, height,
PixelFormat.Format24bppRgb)
Dim g As Graphics = Graphics.FromImage(bmp)

g.TextRenderingHint = TextRenderingHint.AntiAlias
g.Clear(Color.Orange)
g.DrawRectangle(Pens.White, 1, 1, width - 3, height - 3)
g.DrawRectangle(Pens.Gray, 2, 2, width - 3, height - 3)
g.DrawRectangle(Pens.Black, 0, 0, width, height)
g.DrawString(Request.QueryString("overlaytext"), _
New Font("Arial", 14, FontStyle.Italic), _
SystemBrushes.WindowText, New PointF(x, 50))
bmp.Save(Response.OutputStream, ImageFormat.Jpeg)
g.Dispose()
bmp.Dispose()
Response.End()

End Sub

End Class

Heres my web form (ASPX) page:

<%@ Page Language="VB" ContentType="image/jpeg" %>


Hope someone can help! :)

Regards,

Simon.
 
G

Guest

I noticed the lack of codebehind and inherits attributes in the aspx. ASP.NET
needs some way to associate the code with the content.
 
W

Web Team @ Borough of Poole

Hi Brad,

THANK YOU! Working AOK now!

For the benefit of the audience...

My ASPX page directive now reads:
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="dynamic_image_text.aspx.vb"
Inherits="myr_project_name.dynamic_image_text" ContentType="image/jpeg"
%>

Thanks again!

Simon.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top