Introduction
This is version 3.0 of the VsCustomRenderer
control. You can find the previous versions here: 2.0 and 1.0.
Background
This project was inspired by an article on CodeProject written by dev2dev: Create Dynamic Images in ASP.NET. Parts of the code were taken from that project.
Using the Code
To test this control:
- Open or create a website.
- Add the VSCustomRendererLibrary reference to the website.
- Add the following line in the
<httpHandlers>
section in the web.config:
<add verb="*" path="*.jpg"
type="VSCustomRendererLibrary.VsImageHandler, VSCustomRendererLibrary"/>
If you cannot find this section in your web.config file, just create it under <system.web>
:
<system.web>
......
<httpHandlers>
<add verb="*" path="*.jpg"
type="VSCustomRendererLibrary.VsImageHandler, VSCustomRendererLibrary"/>
</httpHandlers>
</system.web>
- Open/create a new ASPX page.
- Add a
SqlDataSource
connected to a SQL table or view (this project was tested with SQL Server 2005 EE).
- Add a
GridView
and connect it to the SqlDataSource
.
- In the
GridView
, add the image column and transform it into a template field.
- Select Edit Template from the
GridView
toolbar menu.
- Add a
VSCustomRenderer
into the ItemTemplate
. Bind the control to the DataSource
field.
Points of Interest
This Web Control now works with AJAX. This control no longer saves images to disk in order to display them. The pictures are displayed directly from memory through an IHttpHandler
. This HTTP handler does not open a new database connection, it just displays the images from memory, so there are no delays in page rendering and no extra parameters to set.
History
All the versions of this control are also posted on CodePlex.