Yeah, that is the preferred way. Original poster however asked how to do
that all with a server control, so I thought he had considered HtttpHandler
option already.
--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke
"Fred Hirschfeld" <> wrote in message
news:...
The way I deal with this is to have the Image resources for my custom
controls embedded in the DLL (of the Class Library, not a part of the site).
I have created an HttpHandler to handle the requests and configured the IIS
Application to send requests for .ERES to my handler. I can then use a path
to the DLL specially formatted URL to access any image resource. This works
extremely well for packaging up you images (or any content including .js
files) for distribution but has a small issue with design visibility that I
am currently working on.
I have attached all the code for the handler to this message and the
following code is how you would use it:
string urlString =
HttpHandlers.HttpEmbeddedResourceHandler.GetResour ceURL(this.Context,
this.GetType().Assembly, "Controls/Images/UpdateButton.gif");
The UpdateButton.gif file in the project is in the Controls/Images directory
and it's "Build Action" is set to Embedded Resource.
Hope this all helps!
Fred
----- Following is the comment on the attached source file...
This HttpHandler is used to extract embedded resources for controls. There
are a couple of configuration
settings that must be done before an application can actually use the
controls (to use the embedded
resources).
1) The Web Application must be configured (using IIS console) to have an
additional mapping under the
configuration tab. Add a new mapping that has the "aspnet_isapi.dll" as
the executable and .eres as the
file extension. Make sure to unselect the "Check that file exists"
checkbox as these files do not actually
exist.
2) Add the following mapping to the web.config file under <system.web>
<httpHandlers>
<add verb="*" path="*.eres"
type="SierraSystems.Web.HttpHandlers.HttpEmbeddedR esourceHandler,
SierraSystems.Web"
validate="true" />
</httpHandlers>
Controls can now create a URL to the embedded resources, the format of the
URL is:
http://webserver/appname/[AssemblyName]/[ResourcePath].eres
EG:
http://webserver/app/SierraSystems.W...utton.gif.eres
"Teemu Keiski" <> wrote in message
news:%...
> Well,
>
> in strict sense you can't as query strings are global for entire request,
> but certainly if you do the checking it in say OnInit (of the control), it
> is unlikely that anything else has something going by that time. And you
can
> call HttpApplication.CompleteRequest to end the request processing after
> control has done its job.
>
> --
> Teemu Keiski
> MCP, Microsoft MVP (ASP.NET), AspInsiders member
> ASP.NET Forum Moderator, AspAlliance Columnist
> http://blogs.aspadvice.com/joteke
>
> "Stephen Walch" <> wrote in message
> news:u$...
> OK, If I do the rendering from my control as you describe, how can I make
> sure that ONLY my control (and nothing else on the page) responds to
certain
> Query strings?
>
> "Teemu Keiski" <> wrote in message
> news:%233iK4%...
> > And to add to the previous, this "rendering case" of course could be
> > detected/done inside the control as well. You could do it in overridden
> > OnInit or OnLoad methods, so that the logic could be contained in the
> > control.
> >
> > --
> > Teemu Keiski
> > MCP, Microsoft MVP (ASP.NET), AspInsiders member
> > ASP.NET Forum Moderator, AspAlliance Columnist
> > http://blogs.aspadvice.com/joteke
> >
> >
> > "Stephen Walch" <> wrote in message
> > news:...
> > Trying to think through how to create a server control (or user control)
> > that renders some HTML plus any needed images. The rendered HTML would
> > include IMG tags with URLs that point back to the same page in such a
way
> > that my server control would have a chance to render the image as well.
> > There are plenty of examples of dynamic image rendering that use a
> PageLoad
> > event or HttpHandler (ASHX page) but I can not figure out how to contain
> > everything in one server control. Any suggestions or pointers to
samples
> > would be much appreciated.
> >
> > Thanks,
> > - Steve
> >
> >
> >
>
>
>