User1810039979 posted
This is my first time using the System.Drawing Namespace and I'm having an issue creating the image. I keep getting the message that I have too many arguments when i try to save the image, although all the tutorials I've seen show a path argument and
a file format argument. When I remove one argument I still get the message. When I remove both arguments I get no error which makes me think its saving the image somewhere without me specifying a location! Here is my VB.NET codebehind.
1 Imports System.Math
2 Imports System.Drawing
3 Imports System.Drawing.Imaging
4
5 Partial Class nameofthepage
6 Inherits System.Web.UI.Page
7
8 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) HAndles Me.Load
9 Panel1.Visible = False
10 End Sub
11
12 Protected Sub MyQueryResults_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyQueryResults.SelectedIndexChanged
13 Dim mapImage As New Bitmap(200, 220)
14 Dim myMapObject As Graphics
15 myMapObject = Graphics.FromImage(mapImage)
16 myMapObject.Clear(Color.Gray)
17
18 Dim mapTitle As String
19 mapTitle = MyQueryResults.SelectedDataKey(2)
20 myMapObject.Drawstring(mapTitle, New Font("Verdana", 12), Brushes.Black, New PointF(5, 5))
21
22 Dim savefile As String = "http://domain/fold1/fold2/myimage.gif"
23 myMapObject.Save(savefile, ImageFormat.Gif)
24 queryResultsImage.ImageUrl = savefile
25
26 Panel1.Visible = True
27 End Sub
28 End Class
MyQueryResults is a Gridview control
queryResultsImage is an asp Image control
Can anyone tell me what I'm doing wrong? Thanks.