I got a question with my ASP.NET page. On the page I have a form with some textboxes and a submit button. How can I do the following:
- Get data from the textboxes
- Calculate some values
- Draw and place an image after the form using these values.
Third step - is the problem for me.
开发者_JAVA百科Thanks in advance.
P.S. I use C# as code behind language.
Okay, basically the idea behin this is that the image class can write to a stream. What you do is you write the image to the Response.OutputStream.
Bitmap bmp = new Bitmap(x,y);
bmp.Save(Response.OutputStream);
One problem with this, is that a browser still thinks it's recieving HTML, you can change this by changing the ContentType of you're response:
Response.ContentType = "image/jpg"; //Or any other content-type like image/png etc...
That way you're page will return an image instead of html.
In your case, what you probably want to do is create a seperate aspx page, that will return the image based on the data you'll pass to it. That way you can embed it in your website like:
<img src="Image.aspx" />
You can pass the data to it by storing it in a Session or by passing it in the querystring.
精彩评论