开发者

Calculate some data and draw corresponding image in ASP.NET

开发者 https://www.devze.com 2023-01-29 12:34 出处:网络
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:

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:

  1. Get data from the textboxes
  2. Calculate some values
  3. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消