Is there a problem with VS.Net 2003? Here's what I have: Public Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim Flag As New Bitmap(300, 100) Dim X, Y As Integer For X = 0 To (Flag.Height - 1) For Y = 0 To (Flag.Width - 1) Flag.SetPixel(X, Y, Color.Yellow) Next Y Next X For X = 0 To (Flag.Height - 1) Flag.SetPixel(X, X, Color.Red) Next X 'PictureBox.AlternateText() = B 'PictureBox = B 'PictureBox.ImageAlign = B 'PictureBox = Flag 'PictureBox.ImageUrl.flag PictureBox.ImageUrl = Flag End Sub I got this code example directly from the VS.Net help. But it doesn't work! I've tried several different approaches with the "PictureBox" line. All don't display the chart. The compiler claims that it should be "PictureBox.Image = Flag", but that gives an error. Where am I going wrong? The second question is what types of controls do I need on the web form and what should they be called? Thanks in advance. May you have a blessed day.
First of all, PictureBox can not be used in ASP.NET form. Instead of it, you need to use Image. However, Image does not work in the same way PictureBox works.
MayurGondaliya (and/or anyone with the answer) .... I've only been using ASP.Net for a little more than a month now. Thank you for pointing out what I shouldn't do. I'm sorry but I must ask for you to be more specific. I don't understand what corrections I should make. Please feel free to elaborate as much as you'd like. Thanks in advance. May you have a blessed day.
Have a look at these, see if they help: http://www.15seconds.com/issue/020924.htm http://www.sitepoint.com/article/generating-asp-net-images-fly/ http://www.developerfusion.com/article/2569/creating-images-on-the-fly-with-aspnet/
Here is the sample code for image rendering using C#, ASP.NET, I hope it helps. Refer http://ask4asp.net/post/sample-code-for-generaing-bar-charts-using-asp-net-c-sharp.aspx System.Drawing.Bitmap b = new System.Drawing.Bitmap(730, 300); for (int i = 0; i < b.Width; i++) { for (int j = 0; j < b.Height; j++) { b.SetPixel(i, j, System.Drawing.Color.FromArgb(216, 216, 216)); } } Random rnd = new Random(10); int BarCount = 0; for (int i = 0; i < b.Width; i++) { b.SetPixel(i, 0, System.Drawing.Color.YellowGreen); b.SetPixel(i, 50, System.Drawing.Color.YellowGreen); b.SetPixel(i, 100, System.Drawing.Color.YellowGreen); b.SetPixel(i, 150, System.Drawing.Color.YellowGreen); b.SetPixel(i, 200, System.Drawing.Color.YellowGreen); b.SetPixel(i, 250, System.Drawing.Color.YellowGreen); } for (int i = 20; i < b.Width; i = i + 30) { BarCount++; if (BarCount == 25) { break; } for (int j = rnd.Next(280); j < b.Height; j++) { b.SetPixel(i + 9, j, System.Drawing.Color.Green); b.SetPixel(i + 8, j, System.Drawing.Color.Green); b.SetPixel(i + 7, j, System.Drawing.Color.Green); b.SetPixel(i + 6, j, System.Drawing.Color.Green); b.SetPixel(i + 5, j, System.Drawing.Color.Green); b.SetPixel(i + 4, j, System.Drawing.Color.Green); b.SetPixel(i + 3, j, System.Drawing.Color.Green); b.SetPixel(i + 2, j, System.Drawing.Color.Green); b.SetPixel(i + 1, j, System.Drawing.Color.Green); b.SetPixel(i, j, System.Drawing.Color.Green); } } for (int i = 0; i < 1; i++) { for (int j = 0; j < b.Height; j++) { b.SetPixel(i, j, System.Drawing.Color.Black); } } for (int i = 0; i < b.Width; i++) { for (int j = b.Height - 1; j < b.Height; j++) { b.SetPixel(i, j, System.Drawing.Color.Black); } } b.Save(Server.MapPath("") + "\\Temp.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); ImageMap1.ImageUrl = "Temp.jpg"; Code (markup):
You can't directly assign a bitmap object to the imageurl of an asp.net image control. You will either need to save the bitmap object to a file using the "Save" method of the bitmap object as stated by MayurGondaliya or create an http handler which will create the image