M
Marc Pelletier
Hello,
I have a class (TideClass) which creates a bitmap image as one of its
functions. I want to create a page which has this image embedded amongst
some text. I know that I have to stream the image back from a separate
aspx page.
I have therefore created a page Day1.aspx which gets the instance of tide
from the context handler, calls the DrawChart function and streams it
back.
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
DataForm1 Page1 = (DataForm1)Context.Handler;
tide = Page1.tide;
}
Bitmap b = new Bitmap( 500, 350 );
b = tide.DrawChart1( 500, 350 );
Response.ContentType = "image/jpeg";
b.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
Response.End();
b.Dispose();
}
The calling page (TideForm.aspx) instantiates the tide object and fills
some labels with properties of the tide object, then calls Day1.aspx to
draw the chart. It also references the original page to get the user
selection:
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
DataForm1 Page1 = (DataForm1) Context.Handler;
Label1.Text = String.Format( "Station ID: {0}", Page1.Station_ID );
Label3.Text = String.Format( "{0:MMM dd, yyyy}", Page1.StartDate );
tide = new TideClass( Page1.Station_ID );
Page1.tide = tide;
tide.CalcDays( sdate, Page1.NumDays );
Label2.Text = tide.StationName;
Server.Transfer("OneDay.aspx");
}
However the resulting page contains ONLY the chart and not the labels
which I would have thought were streamed first. This confirms that my
code on Day1.aspx is correct, at least.
My next effort was to include an image on TideForm. I dropped a
WebControl.Image on there and set the imageurl to Day1.aspx. I've tried
setting the imageurl property dynamically after I know the tide object
has been created, and I've set the url statically, but a breakpoint in
the Day1.Page_load method never gets triggered and the image is displayed
empty.
I'm stumped. None of the examples I've found places an image on a page
with other elements.
I guess my question is how do I display dynamic data in a Webcontrol
Image component? Alternatively, how do I embed an image within other
content?
thanks
Marc Pelletier
I have a class (TideClass) which creates a bitmap image as one of its
functions. I want to create a page which has this image embedded amongst
some text. I know that I have to stream the image back from a separate
aspx page.
I have therefore created a page Day1.aspx which gets the instance of tide
from the context handler, calls the DrawChart function and streams it
back.
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
DataForm1 Page1 = (DataForm1)Context.Handler;
tide = Page1.tide;
}
Bitmap b = new Bitmap( 500, 350 );
b = tide.DrawChart1( 500, 350 );
Response.ContentType = "image/jpeg";
b.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
Response.End();
b.Dispose();
}
The calling page (TideForm.aspx) instantiates the tide object and fills
some labels with properties of the tide object, then calls Day1.aspx to
draw the chart. It also references the original page to get the user
selection:
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
DataForm1 Page1 = (DataForm1) Context.Handler;
Label1.Text = String.Format( "Station ID: {0}", Page1.Station_ID );
Label3.Text = String.Format( "{0:MMM dd, yyyy}", Page1.StartDate );
tide = new TideClass( Page1.Station_ID );
Page1.tide = tide;
tide.CalcDays( sdate, Page1.NumDays );
Label2.Text = tide.StationName;
Server.Transfer("OneDay.aspx");
}
However the resulting page contains ONLY the chart and not the labels
which I would have thought were streamed first. This confirms that my
code on Day1.aspx is correct, at least.
My next effort was to include an image on TideForm. I dropped a
WebControl.Image on there and set the imageurl to Day1.aspx. I've tried
setting the imageurl property dynamically after I know the tide object
has been created, and I've set the url statically, but a breakpoint in
the Day1.Page_load method never gets triggered and the image is displayed
empty.
I'm stumped. None of the examples I've found places an image on a page
with other elements.
I guess my question is how do I display dynamic data in a Webcontrol
Image component? Alternatively, how do I embed an image within other
content?
thanks
Marc Pelletier