By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,112 Members | 1,628 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,112 IT Pros & Developers. It's quick & easy.

how to render a graphic and other objects in the same page?

P: n/a
Hi,

I try to create and render a graphic among other objects like e.g. tables,
labels, buttons.
The tables are not a problem, neither the graphic.

My problem is that i can't render both together. With the code below, i only
see the graphic, nothing else (no table, label, button).

How can i see the table and below the table, the graphic?
Thanks
André

My code:
Dim objBitmap As New Bitmap(400,200)
Dim objGraphic as Graphics = Graphics.FromImage(objBitmap)
Dim redBrush As New SolidBrush(Color.Red)
Dim blueBrush As New SolidBrush(Color.Blue)
Dim greenBrush As New SolidBrush(Color.Green)
Dim whiteBrush As New SolidBrush(Color.White)
Dim blackPen As New Pen(Color.Black, 2)
Dim sngheight(10) As Single
Dim sngValue(10) As Single
Dim max, x As Integer

.....

c = New TableCell
c.Text() = "this is a tablecell"
r.Cells.Add(c) 'add to row
t.Rows.Add(r) 'add to table
frm.Controls.Add(t) 'add to form
lit = New LiteralControl("<br>")
frm.Controls.Add(lit)

objGraphic.FillRectangle(whiteBrush, 0, 0, 400, 200)
objGraphic.DrawString("A525G", New Font("Arial", 10), New
SolidBrush(Color.White), 35, 8)

objGraphic.DrawLine(blackPen, New Point(0, 195), New Point(350, 195))
objGraphic.DrawLine(blackPen, New Point(5, 5), New Point(5, 200))
....

For i = 1 To 10
sngHeight(i) = (sngValue(i) / 50+i) * 190
objGraphic.FillRectangle(redBrush, 10 + x, 194 - sngHeight(i), 20,
sngHeight(i))
Next

Response.ContentType = "image/gif"
objBitmap.Save(Response.OutputStream, Drawing.Imaging.ImageFormat.Gif)

Nov 27 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
You need at least two pages to accomplish your goal. One to output the
image and one to output the rest of the page (including a link to the
image).

So put your image generation code in a file called "MyImage.aspx"
Now from your original page add an image tag that refers to that new image
page:
<img src="MyImage.aspx"/>

Here's more info:
http://SteveOrr.net/articles/ImproveYourImages.aspx

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"André" <hjhhb@ddwrote in message
news:u1**************@TK2MSFTNGP02.phx.gbl...
Hi,

I try to create and render a graphic among other objects like e.g. tables,
labels, buttons.
The tables are not a problem, neither the graphic.

My problem is that i can't render both together. With the code below, i
only see the graphic, nothing else (no table, label, button).

How can i see the table and below the table, the graphic?
Thanks
André

My code:
Dim objBitmap As New Bitmap(400,200)
Dim objGraphic as Graphics = Graphics.FromImage(objBitmap)
Dim redBrush As New SolidBrush(Color.Red)
Dim blueBrush As New SolidBrush(Color.Blue)
Dim greenBrush As New SolidBrush(Color.Green)
Dim whiteBrush As New SolidBrush(Color.White)
Dim blackPen As New Pen(Color.Black, 2)
Dim sngheight(10) As Single
Dim sngValue(10) As Single
Dim max, x As Integer

....

c = New TableCell
c.Text() = "this is a tablecell"
r.Cells.Add(c) 'add to row
t.Rows.Add(r) 'add to table
frm.Controls.Add(t) 'add to form
lit = New LiteralControl("<br>")
frm.Controls.Add(lit)

objGraphic.FillRectangle(whiteBrush, 0, 0, 400, 200)
objGraphic.DrawString("A525G", New Font("Arial", 10), New
SolidBrush(Color.White), 35, 8)

objGraphic.DrawLine(blackPen, New Point(0, 195), New Point(350, 195))
objGraphic.DrawLine(blackPen, New Point(5, 5), New Point(5, 200))
...

For i = 1 To 10
sngHeight(i) = (sngValue(i) / 50+i) * 190
objGraphic.FillRectangle(redBrush, 10 + x, 194 - sngHeight(i), 20,
sngHeight(i))
Next

Response.ContentType = "image/gif"
objBitmap.Save(Response.OutputStream, Drawing.Imaging.ImageFormat.Gif)
Nov 27 '06 #2

P: n/a
Thanks, i'll try

"Steve C. Orr [MCSD, MVP, CSM, ASP Insider]" <St***@Orr.netschreef in
bericht news:eT**************@TK2MSFTNGP03.phx.gbl...
You need at least two pages to accomplish your goal. One to output the
image and one to output the rest of the page (including a link to the
image).

So put your image generation code in a file called "MyImage.aspx"
Now from your original page add an image tag that refers to that new image
page:
<img src="MyImage.aspx"/>

Here's more info:
http://SteveOrr.net/articles/ImproveYourImages.aspx

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"André" <hjhhb@ddwrote in message
news:u1**************@TK2MSFTNGP02.phx.gbl...
>Hi,

I try to create and render a graphic among other objects like e.g.
tables, labels, buttons.
The tables are not a problem, neither the graphic.

My problem is that i can't render both together. With the code below, i
only see the graphic, nothing else (no table, label, button).

How can i see the table and below the table, the graphic?
Thanks
André

My code:
Dim objBitmap As New Bitmap(400,200)
Dim objGraphic as Graphics = Graphics.FromImage(objBitmap)
Dim redBrush As New SolidBrush(Color.Red)
Dim blueBrush As New SolidBrush(Color.Blue)
Dim greenBrush As New SolidBrush(Color.Green)
Dim whiteBrush As New SolidBrush(Color.White)
Dim blackPen As New Pen(Color.Black, 2)
Dim sngheight(10) As Single
Dim sngValue(10) As Single
Dim max, x As Integer

....

c = New TableCell
c.Text() = "this is a tablecell"
r.Cells.Add(c) 'add to row
t.Rows.Add(r) 'add to table
frm.Controls.Add(t) 'add to form
lit = New LiteralControl("<br>")
frm.Controls.Add(lit)

objGraphic.FillRectangle(whiteBrush, 0, 0, 400, 200)
objGraphic.DrawString("A525G", New Font("Arial", 10), New
SolidBrush(Color.White), 35, 8)

objGraphic.DrawLine(blackPen, New Point(0, 195), New Point(350, 195))
objGraphic.DrawLine(blackPen, New Point(5, 5), New Point(5, 200))
...

For i = 1 To 10
sngHeight(i) = (sngValue(i) / 50+i) * 190
objGraphic.FillRectangle(redBrush, 10 + x, 194 - sngHeight(i), 20,
sngHeight(i))
Next

Response.ContentType = "image/gif"
objBitmap.Save(Response.OutputStream, Drawing.Imaging.ImageFormat.Gif)

Nov 27 '06 #3

P: n/a
Hi Steve, here am i back ...
I did what you told me and it works.

But i have another strange problem. The graphic generated in the second file
(graf2.aspx) must receive values from the the first file. I do that with
cookies. It works when i send ONE cookie, but if i send two cookies from the
first file, i get the browser-error: "can't render the page (or something
like that) ... check your configuration etc ...".

Maybe a conflict between the 'Response'?
Can you see the problem and maybe solve it?
Thanks
I show you my code:
first file:
-------
Dim cok1 As New HttpCookie("cok1")
Dim cok2 As New HttpCookie("cok2")
cok1.Value = 150
Response.Cookies.Add(cok1)
cok2.Value = 50
Response.Cookies.Add(cok2)
.....
lit = New LiteralControl("<img src=""graf2.aspx""/>")
frm.Controls.Add(lit)
.....

graf2.aspx
--------------------------------
Sub Page_Load(sender As Object, e As EventArgs)
Dim cok1 As New HttpCookie("cok1")
Dim cok2 As New HttpCookie("cok2")
Dim ja1, ja2 As String
Dim az,az2 As Integer
cok1 = Request.Cookies("cok1")
cok2 = Request.Cookies("cok2")
ja1 = cok1.Value
ja2 = cok2.Value
az = Convert.ToInt16(ja1) 'used in the graphic
az2 = Convert.ToInt16(ja2) 'used in the graphic
....
Dim objBitmap As New Bitmap(300, 200)
Dim objGraphic as Graphics = Graphics.FromImage(objBitmap)
etc ...
.......
end sub


"Steve C. Orr [MCSD, MVP, CSM, ASP Insider]" <St***@Orr.netschreef in
bericht news:eT**************@TK2MSFTNGP03.phx.gbl...
You need at least two pages to accomplish your goal. One to output the
image and one to output the rest of the page (including a link to the
image).

So put your image generation code in a file called "MyImage.aspx"
Now from your original page add an image tag that refers to that new image
page:
<img src="MyImage.aspx"/>

Here's more info:
http://SteveOrr.net/articles/ImproveYourImages.aspx

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"André" <hjhhb@ddwrote in message
news:u1**************@TK2MSFTNGP02.phx.gbl...
>Hi,

I try to create and render a graphic among other objects like e.g.
tables, labels, buttons.
The tables are not a problem, neither the graphic.

My problem is that i can't render both together. With the code below, i
only see the graphic, nothing else (no table, label, button).

How can i see the table and below the table, the graphic?
Thanks
André

My code:
Dim objBitmap As New Bitmap(400,200)
Dim objGraphic as Graphics = Graphics.FromImage(objBitmap)
Dim redBrush As New SolidBrush(Color.Red)
Dim blueBrush As New SolidBrush(Color.Blue)
Dim greenBrush As New SolidBrush(Color.Green)
Dim whiteBrush As New SolidBrush(Color.White)
Dim blackPen As New Pen(Color.Black, 2)
Dim sngheight(10) As Single
Dim sngValue(10) As Single
Dim max, x As Integer

....

c = New TableCell
c.Text() = "this is a tablecell"
r.Cells.Add(c) 'add to row
t.Rows.Add(r) 'add to table
frm.Controls.Add(t) 'add to form
lit = New LiteralControl("<br>")
frm.Controls.Add(lit)

objGraphic.FillRectangle(whiteBrush, 0, 0, 400, 200)
objGraphic.DrawString("A525G", New Font("Arial", 10), New
SolidBrush(Color.White), 35, 8)

objGraphic.DrawLine(blackPen, New Point(0, 195), New Point(350, 195))
objGraphic.DrawLine(blackPen, New Point(5, 5), New Point(5, 200))
...

For i = 1 To 10
sngHeight(i) = (sngValue(i) / 50+i) * 190
objGraphic.FillRectangle(redBrush, 10 + x, 194 - sngHeight(i), 20,
sngHeight(i))
Next

Response.ContentType = "image/gif"
objBitmap.Save(Response.OutputStream, Drawing.Imaging.ImageFormat.Gif)

Nov 29 '06 #4

P: n/a
I don't like cookies much; they're not very reliable.
I'd suggest you look into sending the parameters via QueryString instead.

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"André" <hjhhb@ddwrote in message
news:O%****************@TK2MSFTNGP02.phx.gbl...
Hi Steve, here am i back ...
I did what you told me and it works.

But i have another strange problem. The graphic generated in the second
file (graf2.aspx) must receive values from the the first file. I do that
with cookies. It works when i send ONE cookie, but if i send two cookies
from the first file, i get the browser-error: "can't render the page (or
something like that) ... check your configuration etc ...".

Maybe a conflict between the 'Response'?
Can you see the problem and maybe solve it?
Thanks
I show you my code:
first file:
-------
Dim cok1 As New HttpCookie("cok1")
Dim cok2 As New HttpCookie("cok2")
cok1.Value = 150
Response.Cookies.Add(cok1)
cok2.Value = 50
Response.Cookies.Add(cok2)
....
lit = New LiteralControl("<img src=""graf2.aspx""/>")
frm.Controls.Add(lit)
....

graf2.aspx
--------------------------------
Sub Page_Load(sender As Object, e As EventArgs)
Dim cok1 As New HttpCookie("cok1")
Dim cok2 As New HttpCookie("cok2")
Dim ja1, ja2 As String
Dim az,az2 As Integer
cok1 = Request.Cookies("cok1")
cok2 = Request.Cookies("cok2")
ja1 = cok1.Value
ja2 = cok2.Value
az = Convert.ToInt16(ja1) 'used in the graphic
az2 = Convert.ToInt16(ja2) 'used in the graphic
...
Dim objBitmap As New Bitmap(300, 200)
Dim objGraphic as Graphics = Graphics.FromImage(objBitmap)
etc ...
......
end sub


"Steve C. Orr [MCSD, MVP, CSM, ASP Insider]" <St***@Orr.netschreef in
bericht news:eT**************@TK2MSFTNGP03.phx.gbl...
>You need at least two pages to accomplish your goal. One to output the
image and one to output the rest of the page (including a link to the
image).

So put your image generation code in a file called "MyImage.aspx"
Now from your original page add an image tag that refers to that new
image page:
<img src="MyImage.aspx"/>

Here's more info:
http://SteveOrr.net/articles/ImproveYourImages.aspx

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"André" <hjhhb@ddwrote in message
news:u1**************@TK2MSFTNGP02.phx.gbl...
>>Hi,

I try to create and render a graphic among other objects like e.g.
tables, labels, buttons.
The tables are not a problem, neither the graphic.

My problem is that i can't render both together. With the code below, i
only see the graphic, nothing else (no table, label, button).

How can i see the table and below the table, the graphic?
Thanks
André

My code:
Dim objBitmap As New Bitmap(400,200)
Dim objGraphic as Graphics = Graphics.FromImage(objBitmap)
Dim redBrush As New SolidBrush(Color.Red)
Dim blueBrush As New SolidBrush(Color.Blue)
Dim greenBrush As New SolidBrush(Color.Green)
Dim whiteBrush As New SolidBrush(Color.White)
Dim blackPen As New Pen(Color.Black, 2)
Dim sngheight(10) As Single
Dim sngValue(10) As Single
Dim max, x As Integer

....

c = New TableCell
c.Text() = "this is a tablecell"
r.Cells.Add(c) 'add to row
t.Rows.Add(r) 'add to table
frm.Controls.Add(t) 'add to form
lit = New LiteralControl("<br>")
frm.Controls.Add(lit)

objGraphic.FillRectangle(whiteBrush, 0, 0, 400, 200)
objGraphic.DrawString("A525G", New Font("Arial", 10), New
SolidBrush(Color.White), 35, 8)

objGraphic.DrawLine(blackPen, New Point(0, 195), New Point(350, 195))
objGraphic.DrawLine(blackPen, New Point(5, 5), New Point(5, 200))
...

For i = 1 To 10
sngHeight(i) = (sngValue(i) / 50+i) * 190
objGraphic.FillRectangle(redBrush, 10 + x, 194 - sngHeight(i), 20,
sngHeight(i))
Next

Response.ContentType = "image/gif"
objBitmap.Save(Response.OutputStream, Drawing.Imaging.ImageFormat.Gif)

Nov 30 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.