|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
how to render a graphic and other objects in the same page?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) 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 Show quoteHide quote "André" <hjhhb@dd> wrote in message news:u15ygLlEHHA.4508@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) > > > Thanks, i'll try
Show quoteHide quote "Steve C. Orr [MCSD, MVP, CSM, ASP Insider]" <St***@Orr.net> schreef in bericht news:eTzgyOlEHHA.4992@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@dd> wrote in message > news:u15ygLlEHHA.4508@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) >> >> >> > 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 Show quoteHide quote "Steve C. Orr [MCSD, MVP, CSM, ASP Insider]" <St***@Orr.net> schreef in bericht news:eTzgyOlEHHA.4992@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@dd> wrote in message > news:u15ygLlEHHA.4508@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) >> >> >> > I don't like cookies much; they're not very reliable.
I'd suggest you look into sending the parameters via QueryString instead. Show quoteHide quote "André" <hjhhb@dd> wrote in message news:O%23tcUE$EHHA.1248@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.net> schreef in > bericht news:eTzgyOlEHHA.4992@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@dd> wrote in message >> news:u15ygLlEHHA.4508@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) >>> >>> >>> >> > >
Repeater and Checkboxs
Charat Control (date Vs date) Dynamicly setting readonly in through a property Custom UpdatePanel - ASP.NET 2.0 and Client Callback Making a GridView Cell read-only Get Datakey Value from Gridview/sqldatasource Help Me WinForm controls in Web Forcing datalist to start new row on demand Question to CreateUserWizard and database |
|||||||||||||||||||||||