|
|
|
|
|
Home
»
AJAX
»
XML-Binary BASE64 image slideshow using ASP. NET - AJAX
|
|
|
|
Total page views :
23534
|
|
Total downloads :
819
|
|
|
|
|
Download
Files:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Similar ArticlesMost ReadTop RatedLatest
|
|
|
|
|
|
|
|
|
|
Introduction
This article would illustrate how to create and use HTTPHandler in ashx file, XML binary base64 to change image format, using Asp.net / Ajax. This primarily aims to have a slide show which displays many user profiles and photos.
The Problem Statement
I was looking to develop a functionality to create a web-based slide show. The features include display more web pages on the click of Previous & Next buttons. Employees & their information in the organization have to be dynamically generated & shown. Normally, we can use a page method to load images to the slide for showing dynamic slides. It should display some transition effects, and it should not cause page refreshment. While using the conventional methods, I faced much problems in extracting binary data from tables & convert into images & render it in web pages. So there is a necessity to arrive at a feasible solution of converting binary information (the image is stored in tables in binary form).
Solution approach
In order to over come all these problems, I thought of using XML binary base64 which includes the HTTP handler object, used to convert binary information into images.
In the link provided below, we could click the next & last buttons to browse the various user profiles. Ajax was used to implement the clicking of Previous & Next buttons for display and to avoid the page from refreshing, I used AJAX. There are a lot of AJAX frameworks and tools out there to choose from. But for this task, I used the ASP.NET 2.0 built-in AJAX.
HTTP Handler
HTTPHandler aspx file contains more features including transition effects. The included source code will demonstrate the use of this class, and also how to use HTTPHandler to make the request to get the next image file and apply the transition effects. The key aspect is to apply transition effects, so that the next image would be completely loaded before playing the effects, otherwise, the picture displayed will not be smooth and will flicker. All these were addressed in the HTTPHandler object.
If we develop with ASP.NET, we probably spend most of our time creating .aspx files with .cs files as code behind (or perhaps use .ascx files for our controls - and .asmx files for web services) & created an .ashx file (web handler). A web handler file works just like an aspx file except we are one step back away from the messy browser level where HTML and C# mix. One reason we would write an .ashx file instead of an .aspx file is that our output doesn't go to the browser directly. Working with .ashx keeps us away from all the browser technology we don't need in this case. We have to include the IsReusable property.
Purpose of HTTPHandler
It really takes a HTTPContext object and work out what to do with it. The best way to describe it would be with an example - Usually we associate an HTTPHandler with either a new file type (eg. ".AGASP") or with a .ASHX file. In the pipeline, the Handler is called last and when it is called, the appropriate HTTPHandler is executed. The handler can print information out or analyze information. The HTTPApplication object will call the HTTPHandler to process the request and generate a response. In this case, we can associate the HTTPHandler with the .stime extension and get it display the server time, when called.
They differ from HTTPModules because it has only one method, one property and no events.
Public Interface IHTTPHandler Public ReadOnly Property IsReuseable as Boolean Public Sub ProcessRequest(context as HttpContext) End Interface
XML Binary Base64 Data
The XML data is present in binary format: base64 format. If we use large files, it takes more time for opening. Images are stored in SQL server as image type (data type). I created SQL scheduler so that on a daily basis transfer of xml data to the slide show (Asp.net birthday folder) server automatically.
SQL Server 2000 Server-Side XML
The major elements of server-side XML support in SQL Server 2000 are as follows:
- The creation of XML fragments from relational data using the FOR XML extension to the SELECT statement.
- The ability to shred XML data, using the OPENXML function, so that it can be imported into relational tables.
- Storing XML data natively in the database.
FOR XML
The FOR XML extension allows the creation of XML from relational data. It supports several "modifiers" that dictate the shape of the resulting XML fragment. Following is the full syntax of the FOR XML clause:
FOR XML {RAW | AUTO | EXPLICIT} [, XMLDATA] [, ELEMENTS] [, BINARY BASE64]
For Example:
Create table [dbo].[testimagestore]
( [imgid] [int] identity(1,1) not null, [image_type] [nvarchar](150) collate sql_latin1_general_cp1_ci_as null,[img] [image] null, constraint [pk_testimagestore] primary key clustered ([imgid] asc) with (pad_index = off, ignore_dup_key = off) on [primary] ) on [primary] textimage_on [primary]
And also using select statement like
select * from dbo.testimagestore for xml auto,elements, binary base64
In the above example XML file employee photo, data is present in binary base64 format. This format would be changed to image format.
Using Source code - Procedure
To use the source code, unzip the project files to a folder, load the imageSlideShow.aspx in Visual Studio 2005, and run it.
|
|
|
Login
to add your contents and source code to this article
|
|
|
|
|
|
|
|
|
|
|
|
|
|
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional
consulting company, our consultants are well-known experts in .NET and many of them
are MVPs, authors, and trainers. We specialize in Microsoft .NET development and
utilize Agile Development and Extreme Programming practices to provide fast pace
quick turnaround results. Our software development model is a mix of Agile Development,
traditional SDLC, and Waterfall models.
|
|
Click here to learn more about C# Consulting. |
|
|
|
|
|
|
|
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon.
Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees.
As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
|
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
|
Go.NET
Build custom interactive diagrams, network, workflow editors, flowcharts, or software design tools. Includes many predefined kinds of nodes, links, and basic shapes. Supports layers, scrolling, zooming, selection, drag-and-drop, clipboard, in-place editing, tooltips, grids, printing, overview window, palette. 100% implemented in C# as a managed .NET Control. Document/View/Tool architecture with many properties&events. Optional automatic layout.
|
Dundas Software
Dundas Chart for .NET is the most advanced .NET charting package available today. With an extremely complete feature set, elegant architecture and easy implementation, Dundas Chart can quickly add advanced Charting functionality to enhance and transform ASP.NET and Windows Forms applications. Whether you are implementing charting into internal projects, or building applications for clients, Dundas Chart offers advanced technology and advanced results to get the most out of data.
|
Clickatell's SMS Gateway
Clickatell's Developer Solutions allow you to SMS enable any website or
application via a range of API's. Learn More about our API connections.
|
Microsoft Visual Studio 2010 Professional
Microsoft Visual Studio 2010 Professional will launch on April 12, but you can beat the rush and secure your copy today by pre-ordering at the affordable estimated retail price of $549 (US). Pre-order now.
|
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
|
Developer-Ready ASP.NET 2.0 Web Hosting with 3 MONTHS FREE
Now supporting .NET 3.0 Framework with Windows Workflow Foundation, Windows Communication Foundation (WCF), Windows Presentation Foundation (WPF), windows CardSpace (WCS)! Providing more flexibility for Developers with Web Services Support and a User/Permission Manger. Also supporting MS SQL 2005/2000 with Real-Time Backups, FREE Automated Attach .MDF Tool, FREE SQL Restore and Shrink SQL DB Tools, and SQL
|
|
|
|
|
|
|
|
|
Download
Files:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|