Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Image within a custom control

Reply
Thread Tools

Image within a custom control

 
 
bobben
Guest
Posts: n/a
 
      02-04-2004
Does anyone know if it is possible to emit a imagebutton with a bitmap
within a custom control.
In other words; I want the custom control to be selfcontained, and not have
to rely on a aspx page to be able to display an imagebutton with a
dynamically stored image. (From a database or loaded from a resource file.)

All I can find is this:

(...)
MemoryStream tempStream = new MemoryStream();

bitmap.Save(Page.Response.OutputStream,ImageFormat .Gif );

But then I am relying on a separate aspx page as a source for my
imagebutton.

Anyone knows any good techniques?

BÝrge


 
Reply With Quote
 
 
 
 
Jiho Han
Guest
Posts: n/a
 
      02-04-2004
I doubt what you're trying to accomplish is possible if I'm getting you
correctly. I've been wanting to do something similar but I just don't see
how that can be achieved. Remember in order for an image to show up on a
HTML page is through <IMG> tag and that src must point at a resource, real
or not.

You can kind of make it self-contained and this is from a book.
Normally your control will be deployed using a setup program that installs
your control and related files in a predetermined location. For example,
you are guaranteed to have /aspnet_client folder under your webroot. i.e.
C:\inetpub\wwwroot\aspnet_client. It's guaranteed to be there because
ASP.NET uses it. Under it, there are folders and subfolders based on your
assembly name and version.

aspnet_client
system_web
1_1_4322

under it you will find a couple of .js files that ASP.NET uses for
validation and etc. You can have your setup file do the same and create a
folder underneath aspnet_client according to your assembly's name and
version and place all your client related files such as images, stylesheets,
..js scripts, behaviors, xml files, xsl files, and anything else you want.
And you can refer to the resources in your control.

Your machine.config file contains this section under system.web and so you
can retrieve the client file location without hardcoding it should they
change in the future or maybe you just want it in a different place
altogether.

<webControls clientScriptsLocation="/aspnet_client/{0}/{1}/"/>

You can retrieve the assembly information like this:

AssemblyName assemblyName = YourControl.GetType().Assembly.GetName();
string assembly = assemblyName.Name.Replace(".", "_").ToLower();
string version = assemblyName.Version.ToString().Replace(".", "_");

and just concat them.
This is straight out of Nikhil Kothari's server controls book by the way and
I recommend you get it if you don't already. It's got a lot of stuff in
there and although personally I don't think he explains things clearly as to
why things work as they do, it's still an invaluable resource for control
developers and everyone should own a copy. The only problem so far is for
design-time support and I'm still devising a way to do this.

Well, good luck.
Jiho

"bobben" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Does anyone know if it is possible to emit a imagebutton with a bitmap
> within a custom control.
> In other words; I want the custom control to be selfcontained, and not

have
> to rely on a aspx page to be able to display an imagebutton with a
> dynamically stored image. (From a database or loaded from a resource

file.)
>
> All I can find is this:
>
> (...)
> MemoryStream tempStream = new MemoryStream();
>
> bitmap.Save(Page.Response.OutputStream,ImageFormat .Gif );
>
> But then I am relying on a separate aspx page as a source for my
> imagebutton.
>
> Anyone knows any good techniques?
>
> BÝrge
>
>



 
Reply With Quote
 
 
 
 
Antonio Bakula
Guest
Posts: n/a
 
      02-05-2004
On Wed, 4 Feb 2004 11:27:33 +0100, bobben wrote:

> Does anyone know if it is possible to emit a imagebutton with a bitmap
> within a custom control.
> In other words; I want the custom control to be selfcontained, and not have
> to rely on a aspx page to be able to display an imagebutton with a
> dynamically stored image. (From a database or loaded from a resource file.)
>
> All I can find is this:
>
> (...)
> MemoryStream tempStream = new MemoryStream();
>
> bitmap.Save(Page.Response.OutputStream,ImageFormat .Gif );
>
> But then I am relying on a separate aspx page as a source for my
> imagebutton.
>
> Anyone knows any good techniques?
>



I have created TStreamImage class that is descendant from
System.Web.UI.WebControls.Image, this class adds functionality to read
image from memory stream. Control works in design time also, but only in
VS.NET and Delphi .NET, well almost working

Control uses http module, when user assigns MemoryStream to control, stream
is stored and fake url is generated, then in normal rendering of web page
image itself generates another request with this fake url, and http module
intercepts this request, streams back saved image to the browser and ends
http request. Only thing that you (or user of this control) had to do is
register http module in web.config of current web application.

Control will try to add it's module in design time, i had *LOT OF* problems
with this one, specially getting the path of web.config in design time. So
be sure to check if web.config is configured properly.

Since I don't like to solve same problem again and again I created
separate assembly to deal with registering HttpModule.

You can download these controls with source code and some additional
readme. Be warned that this code is still under *heavy* development and I
will really like to hear some comments, and specially any improvements of
this code or idea.

Code is written in Delphi, but there are some example projects that use
this controls in c#

You can download it from :

http://baksa.europe.webmatrixhosting.net/

As you can read my English is not very best, sorry

--
!Antonio
remove XremoveX from e-mail address
AntiSpam Fodder:
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
bobben
Guest
Posts: n/a
 
      02-06-2004
I figured it out....sort of.... It seems that this can be solved using the
tag:
<img src="data:image/gif;base64,'.<base64encodedImageString>.'

This is however only supported by 4.01 compliant browsers (or something
like that) AND IE is not compliant.

Great! I see that this is supported in ASP.Net 2.0 with the Webresource
feature.... just have to wait.



Thanks anyway!
BÝrge

"Antonio Bakula" <(E-Mail Removed)> wrote in message
news:j3bc25qsgeei$.fqd4hxcdhl2p$(E-Mail Removed)...
> On Wed, 4 Feb 2004 11:27:33 +0100, bobben wrote:
>
> > Does anyone know if it is possible to emit a imagebutton with a bitmap
> > within a custom control.
> > In other words; I want the custom control to be selfcontained, and not

have
> > to rely on a aspx page to be able to display an imagebutton with a
> > dynamically stored image. (From a database or loaded from a resource

file.)
> >
> > All I can find is this:
> >
> > (...)
> > MemoryStream tempStream = new MemoryStream();
> >
> > bitmap.Save(Page.Response.OutputStream,ImageFormat .Gif );
> >
> > But then I am relying on a separate aspx page as a source for my
> > imagebutton.
> >
> > Anyone knows any good techniques?
> >

>
>
> I have created TStreamImage class that is descendant from
> System.Web.UI.WebControls.Image, this class adds functionality to read
> image from memory stream. Control works in design time also, but only in
> VS.NET and Delphi .NET, well almost working
>
> Control uses http module, when user assigns MemoryStream to control,

stream
> is stored and fake url is generated, then in normal rendering of web page
> image itself generates another request with this fake url, and http module
> intercepts this request, streams back saved image to the browser and ends
> http request. Only thing that you (or user of this control) had to do is
> register http module in web.config of current web application.
>
> Control will try to add it's module in design time, i had *LOT OF*

problems
> with this one, specially getting the path of web.config in design time. So
> be sure to check if web.config is configured properly.
>
> Since I don't like to solve same problem again and again I created
> separate assembly to deal with registering HttpModule.
>
> You can download these controls with source code and some additional
> readme. Be warned that this code is still under *heavy* development and I
> will really like to hear some comments, and specially any improvements of
> this code or idea.
>
> Code is written in Delphi, but there are some example projects that use
> this controls in c#
>
> You can download it from :
>
> http://baksa.europe.webmatrixhosting.net/
>
> As you can read my English is not very best, sorry
>
> --
> !Antonio
> remove XremoveX from e-mail address
> AntiSpam Fodder:
> (E-Mail Removed)



 
Reply With Quote
 
Jiho Han
Guest
Posts: n/a
 
      02-06-2004
That's great.

BTW, can you point me at the resource where you found base64 stuff?
Thanks

"bobben" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I figured it out....sort of.... It seems that this can be solved using the
> tag:
> <img src="data:image/gif;base64,'.<base64encodedImageString>.'
>
> This is however only supported by 4.01 compliant browsers (or something
> like that) AND IE is not compliant.
>
> Great! I see that this is supported in ASP.Net 2.0 with the Webresource
> feature.... just have to wait.
>
>
>
> Thanks anyway!
> BÝrge
>
> "Antonio Bakula" <(E-Mail Removed)> wrote in message
> news:j3bc25qsgeei$.fqd4hxcdhl2p$(E-Mail Removed)...
> > On Wed, 4 Feb 2004 11:27:33 +0100, bobben wrote:
> >
> > > Does anyone know if it is possible to emit a imagebutton with a bitmap
> > > within a custom control.
> > > In other words; I want the custom control to be selfcontained, and

not
> have
> > > to rely on a aspx page to be able to display an imagebutton with a
> > > dynamically stored image. (From a database or loaded from a resource

> file.)
> > >
> > > All I can find is this:
> > >
> > > (...)
> > > MemoryStream tempStream = new MemoryStream();
> > >
> > > bitmap.Save(Page.Response.OutputStream,ImageFormat .Gif );
> > >
> > > But then I am relying on a separate aspx page as a source for my
> > > imagebutton.
> > >
> > > Anyone knows any good techniques?
> > >

> >
> >
> > I have created TStreamImage class that is descendant from
> > System.Web.UI.WebControls.Image, this class adds functionality to read
> > image from memory stream. Control works in design time also, but only in
> > VS.NET and Delphi .NET, well almost working
> >
> > Control uses http module, when user assigns MemoryStream to control,

> stream
> > is stored and fake url is generated, then in normal rendering of web

page
> > image itself generates another request with this fake url, and http

module
> > intercepts this request, streams back saved image to the browser and

ends
> > http request. Only thing that you (or user of this control) had to do is
> > register http module in web.config of current web application.
> >
> > Control will try to add it's module in design time, i had *LOT OF*

> problems
> > with this one, specially getting the path of web.config in design time.

So
> > be sure to check if web.config is configured properly.
> >
> > Since I don't like to solve same problem again and again I created
> > separate assembly to deal with registering HttpModule.
> >
> > You can download these controls with source code and some additional
> > readme. Be warned that this code is still under *heavy* development and

I
> > will really like to hear some comments, and specially any improvements

of
> > this code or idea.
> >
> > Code is written in Delphi, but there are some example projects that use
> > this controls in c#
> >
> > You can download it from :
> >
> > http://baksa.europe.webmatrixhosting.net/
> >
> > As you can read my English is not very best, sorry
> >
> > --
> > !Antonio
> > remove XremoveX from e-mail address
> > AntiSpam Fodder:
> > (E-Mail Removed)

>
>



 
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
Custom control within a custom control J R M ASP .Net 2 06-01-2006 06:04 PM
Custom control within repeater with custom object binding - .net 1 =?Utf-8?B?SmF5YnVmZmV0?= ASP .Net 9 02-21-2006 03:38 AM
Capturing event from other custom control within another custom control Jonah Olsson ASP .Net 1 04-05-2005 01:39 PM
Capturing event from other custom control within another custom control Jonah Olsson ASP .Net Web Controls 2 04-05-2005 12:56 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