locked
No Graphics Display RRS feed

  • Question

  • User-1073857897 posted

    Today was my first try at using system.drawing. To my dismay, even though I get no errors, no graphics appear in the browser. Even the simple example from a text book, see below displays nothing - any ideas?

    Example that displays nothing:

    <%@ Page ContentType="image/gif" CodeBehind="SimpleImage.aspx.vb" Language="vb" AutoEventWireup="false" Inherits="GraphicsTestBed.SimpleImage" %> <%@ Page ContentType="image/gif" CodeBehind="SimpleImage.aspx.vb" Language="vb" AutoEventWireup="false" Inherits="GraphicsTestBed.SimpleImage" %>
    <%@ Import namespace="System.Drawing" %>
    <%@ Import namespace="System.Drawing.Imaging" %>

    <Script Runat="Server">

    Sub Page_Load
      Dim objBitmap As Bitmap
      Dim intCounter As Integer
      Dim objRandom As Random

      ' Create Bitmap
      objBitmap = New Bitmap( 400, 200 )

      ' Set 1000 Pixels
      objRandom = New Random
      For intCounter = 1 To 1000
        objBitmap.SetPixel( objRandom.Next( 400 ), objRandom.Next( 200 ), Color.Red )
      Next

      ' Display Bitmap
      objBitmap.Save( Response.OutputStream, ImageFormat.Gif )
    End Sub

    </Script><%@ Import namespace="System.Drawing" %><%@ Import namespace="System.Drawing.Imaging" %> <script Runat="Server"> </script>

    Sunday, November 27, 2005 5:00 PM

All replies

  • User2128074059 posted
    You can only replace the first line above with the following line.
    <%@ Page Language="vb" %>

    And the effect you want to view will be showed at this link:
    http://photosprite.net/test/upload/effect.aspx
    Sunday, November 27, 2005 9:30 PM
  • User-1073857897 posted
    Thanks, that worked fine. I guess the codebhind bit was stopping the page_load routine in the aspx page from functioning?
    Sunday, November 27, 2005 10:37 PM