Why doesn't this work?
-
I had this working in my project, then I wanted to use this code in another project and now it refuses to save a BMP file. Please someone tell my what I overlook. Ranger. float range = 1.5F; float startRe = -0.7F; float startIm = 0.27015F; int startColor = 60; public Bitmap objBitmap = new Bitmap(300, 300); public Graphics objGraphic; public Pen myPen = new Pen(Color.Red); protected void enterButton_Click(object sender, EventArgs e) { if (Page.IsValid) { objGraphic = Graphics.FromImage(objBitmap); MakeJuliaSetBmp(); // Do the drawing Response.ContentType = "image/bmp"; MakeUniqueFileName(); // makes a unique filename for the BMP file objBitmap.Save(Request.PhysicalApplicationPath + "/pictures/" + filename, ImageFormat.Bmp); Response.Flush(); objGraphic.Dispose(); objBitmap.Dispose(); myPen.Dispose(); } } Novice
-
I had this working in my project, then I wanted to use this code in another project and now it refuses to save a BMP file. Please someone tell my what I overlook. Ranger. float range = 1.5F; float startRe = -0.7F; float startIm = 0.27015F; int startColor = 60; public Bitmap objBitmap = new Bitmap(300, 300); public Graphics objGraphic; public Pen myPen = new Pen(Color.Red); protected void enterButton_Click(object sender, EventArgs e) { if (Page.IsValid) { objGraphic = Graphics.FromImage(objBitmap); MakeJuliaSetBmp(); // Do the drawing Response.ContentType = "image/bmp"; MakeUniqueFileName(); // makes a unique filename for the BMP file objBitmap.Save(Request.PhysicalApplicationPath + "/pictures/" + filename, ImageFormat.Bmp); Response.Flush(); objGraphic.Dispose(); objBitmap.Dispose(); myPen.Dispose(); } } Novice
Ranger49 wrote:
now it refuses to save
What do you mean? An exception is thrown? The files isn't created? Are you sure the proper rights have been assigned to the destination folder?
only two letters away from being an asset
-
I had this working in my project, then I wanted to use this code in another project and now it refuses to save a BMP file. Please someone tell my what I overlook. Ranger. float range = 1.5F; float startRe = -0.7F; float startIm = 0.27015F; int startColor = 60; public Bitmap objBitmap = new Bitmap(300, 300); public Graphics objGraphic; public Pen myPen = new Pen(Color.Red); protected void enterButton_Click(object sender, EventArgs e) { if (Page.IsValid) { objGraphic = Graphics.FromImage(objBitmap); MakeJuliaSetBmp(); // Do the drawing Response.ContentType = "image/bmp"; MakeUniqueFileName(); // makes a unique filename for the BMP file objBitmap.Save(Request.PhysicalApplicationPath + "/pictures/" + filename, ImageFormat.Bmp); Response.Flush(); objGraphic.Dispose(); objBitmap.Dispose(); myPen.Dispose(); } } Novice
Ranger49 wrote:
public Bitmap objBitmap = new Bitmap(300, 300); public Graphics objGraphic; public Pen myPen = new Pen(Color.Red);
Why are these public ? Why are they members at all ?
Ranger49 wrote:
MakeUniqueFileName
Why does this not return the filename ? It's probable you don't have write permissions on the folder, or it doesn't exist. Hard to say without seeing the error
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Ranger49 wrote:
public Bitmap objBitmap = new Bitmap(300, 300); public Graphics objGraphic; public Pen myPen = new Pen(Color.Red);
Why are these public ? Why are they members at all ?
Ranger49 wrote:
MakeUniqueFileName
Why does this not return the filename ? It's probable you don't have write permissions on the folder, or it doesn't exist. Hard to say without seeing the error
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
The problem is that the enterButton_Click method (which should call a class to compute a fractal which then saves it to a Bmp pic file) never runs. Also my codefile in the App_Code ProduceImageFile.cs never is even run. I wanted the enter.aspx to call the ProduceImageFile.cs but somehow that never happens. In enter.aspx is a startButton_Click method which also never seems to fire, even though it does move you to the display.aspx which is intended to display the computed picture, the wanted calculations are never made on this click. So there may not be any bugs in the code where I expected it, this code never is reached and executed! About the App_Code folder, do you need to do something with the namespace or something to make sure the aspx (cs) file can find it? Hope this is clearer now. Thanks everybody. Ranger. Novice
-
The problem is that the enterButton_Click method (which should call a class to compute a fractal which then saves it to a Bmp pic file) never runs. Also my codefile in the App_Code ProduceImageFile.cs never is even run. I wanted the enter.aspx to call the ProduceImageFile.cs but somehow that never happens. In enter.aspx is a startButton_Click method which also never seems to fire, even though it does move you to the display.aspx which is intended to display the computed picture, the wanted calculations are never made on this click. So there may not be any bugs in the code where I expected it, this code never is reached and executed! About the App_Code folder, do you need to do something with the namespace or something to make sure the aspx (cs) file can find it? Hope this is clearer now. Thanks everybody. Ranger. Novice
Ranger49 wrote:
About the App_Code folder, do you need to do something with the namespace or something to make sure the aspx (cs) file can find it?
No. How are the buttons hooked up to events ? If they are created on the fly, they need to be created in the LoadViewState event, so that they exist when view state is restored, and their events are not lost.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Ranger49 wrote:
About the App_Code folder, do you need to do something with the namespace or something to make sure the aspx (cs) file can find it?
No. How are the buttons hooked up to events ? If they are created on the fly, they need to be created in the LoadViewState event, so that they exist when view state is restored, and their events are not lost.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Christian Graus wrote:
How are the buttons hooked up to events ?
I only got a enterButton_Click method. Is there a LoadViewState event in the properties window of the button? I couldn't find it. Ranger. Novice
As it turned out the code was never even reached. So I made an instance of the class that should generate a bmp file in the Page_Load handler of my enter.aspx. Now it did run, but now I get the message: Response.ContentType = "image/bmp"; not available in this context...! Which is the ProduceImageFile.cs (a class file)I checked all using statements, and I think I got all the ones I need. When you type R you get Response and then you type '.' and C and get Response.ContentType, so I feel this should be available, but for some reason I get an exception that my application cannot handle the Response.ContextType = "image/bmp"; statement. Could anybody tell me how to fix this? It is kind of frustrating to have to spend days on simple things that don't want to work, simply because all those online help files only address the hard issues. I tried these concepts in small projects and got them to run properly, then I tried to encorporate them in a larger application and again it refuses to function! Ranger. Novice.