Archive

Posts Tagged ‘ASP.Net’

DotNetZip – Zip file manipulation in .NET

December 23, 2010 Leave a comment

DotNetZip is a small, easy-to-use class library for manipulating .zip files. It can enable .NET applications written in VB.NET, C#, or any .NET language, to easily create, read, and update zip files. Zip Compression is easy with DotNetZip. The DotNetZip project also produces a GUI ZIP tool, and a few command line tools.

DotNetZip works on Windows-powered PCs with the full .NET Framework, and also runs on Windows Mobile devices that use the .NET Compact Framework. Create and read zip files in VB, C#, or any .NET language. The library can also be used from COM enironments, like PHP, Classic ASP, or VB-Script. DotNetZip supports these scenarios:

  • creating a zip archive, adding files or directories into the archive
  • listing files in an archive, extracting files from an archive
  • modifying an existing archive – renaming entries, removing entries from an archive, or adding new entries to an archive
  • creating zip files from stream content, saving to a stream, extracting to a stream, reading from a stream
  • dynamically creating ZIP files from ASP.NET applications

Read more at http://dotnetzip.codeplex.com/

Categories: ASP.Net, C# Tags: , , , ,

Custom Paging with the ASP.NET Repeater

Unlike DataGrid or GridView control, Repeater does not provide the facility for paging. If we need to show large amount of data and also want to utilize the flexibility of Repeater control, we will have to do some kind of custom paging.

Recently, i had to use paging with ASP.NET Repeater Control. Following URLs helped me in doing so:

http://www.dotnetcurry.com/ShowArticle.aspx?ID=345
http://www.codeproject.com/KB/webforms/Aspnet_Repeater_Control.aspx

These URLs gave me a basic idea on how to do it with Repeater. Difference in my project was that i was not using LINQ so use of Skip() or Take() methods was not possible. I was getting Results (in data-table) using SQLCommand. To resolve this issue, i used the ROW_NUMBER clause provided in SQL Server 2005 onwards. By using ROW_NUMBER() we can easily fetch page wise data. Following is one of the sample queries i used to bind Repeater Control:

/*You can pass these as parameter>>*/
DECLARE @PageIndex AS INT /*Current Page Index (1-based index)*/
DECLARE @PageSize AS INT /*Number of records per page*/
SET @PageSize = 10
SET @PageIndex = 3
/*You can pass these as parameter<<*/

DECLARE @PageStartIndex AS INT
SET @PageStartIndex = ((@PageIndex-1) * @PageSize) + 1
/*Select Page Start Index Based on Current Page*/

SELECT TOP (@PageSize) * FROM (SELECT ROW_NUMBER()  OVER (ORDER BY ItemID) AS RowNum, * FROM HtmlText) AS SelectTable WHERE RowNum >= @PageStartIndex

This query will provide result set based on current page.

Categories: ASP.Net Tags: ,

Web Charting Tools

There are different options available to show charts/graphs on web, each method has its own pro and cons. Following is a quick comparison study on different techniques.

Flash Based Charts:

This is a technique to create a data-set in the form of XML or Java-script arrays and pass that data to flash SWF files. There are some freely available flash based charting solutions. Following are a couple of freely available flash based charting solutions for web:

The advantage of these charts is that all the flexibility of flash (provided by the solution) we can utilize. Flash based charts show very nice animations and transitions. Another advantage is that integration of these charting solution is very easy, we just need to create data-set that is compatible to the solution requirement. This technique is independent of the server-side technology of your web application.

Disadvantage of this technique is that we are dependent on an external package and we are also dependent on the flash player on client side. So these charting solution can only work where flash player is available on client side. So if we are targeting iPhone or iPad as target platform, we should not consider this option.

Crystal Report Based Charts

Crystal Report support charts and graphs. We can show graphical representation of the data in a section of report.

Crystal report has all charting capabilities on design time and it gives no control to developers to modify the behavior/shape of charts on run-time. This makes it difficult for complex charting requirements. This technique is suitable if we have simple charting requirement and charts are shown in-line in a tabular report.

This technique requires Crystal Reports license on server-side and Crystal Report viewer on client side.

ASP.Net Based Charts

Charting capabilities can be utilized in ASP.Net 3.5 by installing Data Visualization Add-on, these Add-ons are available at following URLs:

This technique is very good as it gives full access to charting library to programmers. We can control the shape, behavior, width, height and other attributes based on the data available for charts. Developing and using these charts is more easy as compared to other options. These charts can take Data Sets directly to show data. These charts do not need any extra software on server or client side. These are shown as images on client side. These can be supported on mobile devices including iPhone and iPad. We might need to adjust the width and height according to resolution of the target device.

The only disadvantage of this technique is that it is only available in ASP.Net. It cannot be used in older technologies like ASP and PHP.

Client Side Java-script Based Charts:

This is kind of new technique which is gaining momentum and is being used by more and more sites. There are many free java-script based charting solutions available. Most of these are based on JQuery. Some of the famous JQuery based charting solutions can be found here:

Google also provides a very good charting library which falls in the same category, Google visualization API is free and is very good one.

This technique is good as it load charts/graphs on client side which takes load off from the server. I could not find a reference on how these charts behave in mobile devices.

Categories: ASP.Net Tags: , ,