Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > using a control from within a control

Reply
Thread Tools

using a control from within a control

 
 
Jon Paal
Guest
Posts: n/a
 
      03-03-2006
I am developing a server control which will output some html and would like to have it also to return a bar chart image generated
from this control:

http://www.codeproject.com/aspnet/webchart.asp

how can I call the bar chart control and have it return an image with my html ?



 
Reply With Quote
 
 
 
 
shiretu
Guest
Posts: n/a
 
      03-03-2006
Hi,

In your target page (that containing the generated image) put a <img>
tag with the src pointed to a regular aspx page. The src url can
contain the parameters of your chart embeded in a get form. For
example:

<img src="chartgenerator.aspx?radius=5&slice1=20&slice2 =45&slice3=35>

Now, in chartgenerator.aspx you can get the variables from the "GET"
request, interpret those variables and generate the image accordingly.
For this, you need a image library or you can build your own (don't
reinvent the whel, just search for such a library). After the image was
generated (now, it is contained in a byte array), set the mime type to
the type of the image and Response.WriteBinary(...) the content of the
image.

One more thing....
The <img....> tag can be a Image web control and you can dinamically
build the src in your code associated with the target page (the page
showing the chart)


Hope it helps....

 
Reply With Quote
 
 
 
 
Jon Paal
Guest
Posts: n/a
 
      03-03-2006

thanks for helping, I need a little more assistance.

it appears the example code, from the link, is returning another control to the web form, as opposed to adding an image, using the
code:

"me.controls.add(chart)"

where "chart" is the control that actually produces the final image.

When I try to put "me.controls.add(chart)" into my custom control, it does not pass through to the web form.

How might I add the "chart" control to the output stream of my htmltextwriter ?




"shiretu" <(E-Mail Removed)> wrote in message news:(E-Mail Removed) ups.com...
> Hi,
>
> In your target page (that containing the generated image) put a <img>
> tag with the src pointed to a regular aspx page. The src url can
> contain the parameters of your chart embeded in a get form. For
> example:
>
> <img src="chartgenerator.aspx?radius=5&slice1=20&slice2 =45&slice3=35>
>
> Now, in chartgenerator.aspx you can get the variables from the "GET"
> request, interpret those variables and generate the image accordingly.
> For this, you need a image library or you can build your own (don't
> reinvent the whel, just search for such a library). After the image was
> generated (now, it is contained in a byte array), set the mime type to
> the type of the image and Response.WriteBinary(...) the content of the
> image.
>
> One more thing....
> The <img....> tag can be a Image web control and you can dinamically
> build the src in your code associated with the target page (the page
> showing the chart)
>
>
> Hope it helps....
>



 
Reply With Quote
 
shiretu
Guest
Posts: n/a
 
      03-04-2006
Hi,

It does not matter if the <img......> tag is manually coded into the
HTML part of the page or if it is a control that finally outputs the
tag. All you have to do is to set the src to the page(NOT CONTROL!!!)
that will generate the image. It must be a page,not a control, because
the page is used in the src part of the img tag. Besides, you may want
to set the mime type of the response generated by the page. A control
can't do that because it must be a part of a page (text/html).

So you have to follow 2 steps:

1. Build a page that renders the image. I will call this page
chartgenerator.aspx. This page can take some parameters in a "GET"
request, parameters used to get the chart data. Now, if you access
http://localhost/myapp/chartgenerato...l1&param2=val2 the
output should be a image (JPG,GIF,etc). NO HTML. Just the image. This
is possible if you set the mimetype of the page properly and
Response.WriteBinary(...) the byte array of the image (see prev.
post). I really don't remember now the name of the property for the
mimetype thing. I only know that it is a property of the
System.Web.UI.Page (the base class of your chartgenerator.aspx)

2 a. Add a <img src="chartgenerator.aspx?param1=val1&param2=val2" ....>
to your page containing the chart
OR
2.b Build a control that can generate the tag described at 2.a. With
this method, you can generate the "?param1=val1&param2&val2" of the
link from the control's custom properties. It will be than available at
design time too

Bottom line...
1. You need a page able to generate an image from the parameters
received in a GET request
2. Any dinamically or hardcoded way of building the src attribute of
the img tag
3. Any dinamically or hardcoded way of printing the img tag itself
(along with the generated src) in the final HTML response

Hope it helps...

 
Reply With Quote
 
shiretu
Guest
Posts: n/a
 
      03-04-2006
Oooooops.... I don't know what is the matter with me... I didn't read
your first message verry well (even if it is a short one ). Sorry, I
was missleading you. You can use my method but it is a little more
difficult. Sorry but I really don't know that control at all and I
don't have the time necesarry to play with it (

Sorry again...

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
using User control within a Custom Control RichB ASP .Net 3 09-22-2008 07:39 PM
How do I include a server tag within a javascript parameter which is itself within a HTML element event? mark4asp ASP .Net 2 11-07-2006 06:23 AM
Using values within arrays within a hash to gsub into an input word... Abe Ruby 2 04-15-2006 08:16 PM
Referring to a textbox within a web control within an aspx KatB ASP .Net 0 04-22-2005 07:14 PM
ControlDesigner not invoked on custom control when control is rendered within another custom control Matt Sokol ASP .Net Building Controls 2 08-07-2003 07:13 AM



Advertisments