TechEd India 2010: PPTs, Demos & Code Snippets

I had two sessions at TechEd India 2010 – one on a lap around VS2010 Web and Cloud Development and the other on Lighting up Apps on Windows 7 using the Windows API Code Pack. The entire set of demos and content is given below. Please read to see how to use them.

The entire set is available on this SkyDrive folder. You can download the PPTs and demos for the ones you want. To create the demos yourself, you will also need to download the “Snippets” file and unzip it somewhere. Load these snippets into VS2010 using the Snippet Manager.

Open any of the projects and go through each “page” of code. You will see comments by me where you need to add some snippet. Simply type in the snippet and press tab twice to insert the appropriate code.

Tags: , , ,
Categories: ASP.NET | Development | Microsoft | Windows 7

Actions: E-mail | Permalink | Comment RSSRSS comment feed

Convert/Display PDF & Word Files as Images in .NET

Recently I had to write some code as a sample to be able to display Word and Acrobat files on a Web page in a 2-page view. We couldn’t simply use a plugin or application on the user’s machine to do so. The solution was to export each page out to an image and then display the pages in any way we needed. We therefore needed to do some document export code from our application.

Word to Images

Converting Word files (.DOC & .DOCX) to images was fairly simple, although I do think I probably took a longer approach. The problem is that the older DOC format and the newer DOCX format have different APIs to work with. So instead of doing this, I simply exported them both to XPS and then used the XPS API to retrieve images for each page. This last part was not obvious to me till I found the one line of code required to do this on a forum – I apologize for not linking to this as I can’t find that link anymore. The credit for that part is wholly the original author’s.

PDF to Images

Converting PDF to images was a major issue. There is no direct way of doing this. There are many 3rd party components that are available to do this, but most of them cost a bomb. Some free ones like PDFSharp are able to iterate pages but there is no way to export a complete page to an image without walking through the entire structure of the page and redrawing everything.

This is where I found the GFLAX library. This requires GhostScript for Windows to be installed on the machine as well. You can register the DLL and then reference it in your .NET code.

Code Sample

I’m attaching the entire code sample to this post as a download. The code is released with the open source BSD license. All external components (Word and Office interop assemblies, GFL, etc.) have the copyright of their owners and must be adhered to.


Once you download the attachment and extract it, open it in Visual Studio 2008. Make sure you’ve installed GhostScript from the link above and run a “regsvr32 GFLAX.dll” for the GFLAX Library. Add reference to Microsoft.Office.Interop.Word on your machine (and remove the marked lines from Web.config) from the .NET tab and to GFLAX from the COM tab.

Run the application and upload .doc, .docx and .pdf files and you can then view them in the browser directly.

Two page display of an uploaded Word file. Works with PDF files too.

Tags: , , ,
Categories: ASP.NET | Development | Office | Tips | Download

Actions: E-mail | Permalink | Comment RSSRSS comment feed

WebsiteSpark and What It Means

Yesterday Microsoft made an announcement that has extremely important implications if you are into Web application development. The WebsiteSpark program offers a ton of Microsoft software for free for web developers and web development companies that qualify. You get all these software for 3 years for both development and production usage. The list of software is:

  • 3 licenses of Visual Studio 2008 Professional Edition
  • 1 license of Expression Studio 3
  • 2 licenses of Expression Web 3
  • 4 processor licenses of Windows Web Server 2008 R2
  • 4 processor licenses of SQL Server 2008 Web Edition
  • DotNetPanel control panel

You can read more about the program on Scott Guthrie’s blog post and at the main site.

What I want to explore in this post is what it means for Web development in general. Currently, there is a trend or impression that if you need to create a software for a SME, you need to use the LAMP stack to remain competitive cost-wise. While true to some extent, what you do lose out is in terms of productivity and time-to-market with tools such as VS2008 and the Expression suite. But the cost of entry to use these has often been a pitfall to getting individual Web developers or smaller Web project companies as well as for the SME.

With WebsiteSpark this so-called “advantage” of the LAMP stack goes for a toss. Not only do you get all the tools you need for free for developing projects for SME companies you also get a number of other additional options that help ease your development, such as:

  • The Web Application Toolkits: A set of pre-packaged templates, samples, source code, etc. that can be simply plugged into your site to extend it with some extra features.
  • The Web Platform Installer: Allows you to quickly set up a developer or even production machine with not just the base requirements but also a number of free Web Applications such as WordPress, Umbraco, SugarDRM, DotNetNuke, Moodle etc. by simply following the setup prompts. Take a look at the Web Application Gallery and see how easy it is to setup these without having to mess around with configuration files and database connection settings on Windows.

This basically means that setting up and using Windows as a platform for Web application development not only is easier and faster but also is now available for free! You can also run most of the open source Web apps on Windows with better performance and scalability. So is there any real reason to still go for the LAMP stack? Try the above stuff out and then decide.

Tags: , , , ,
Categories: ASP.NET | Development | Internet | Microsoft | Rave

Actions: E-mail | Permalink | Comment RSSRSS comment feed

Three Articles in August 2009 PCQuest

PCQuest has just published 3 of my articles in their current issue. It was actually supposed to be 4, but the one on ASP.NET 4 got lost in the mail and a resend was received too late for this issue. You can read these articles here:

I’m also going to try and compile a list of articles I’ve written in PCQuest over the last few years and link to them here.

Tags: , , , ,
Categories: Windows 7 | SilverLight | Office | Development | ASP.NET

Actions: E-mail | Permalink | Comment RSSRSS comment feed

Blog Upgrade

I finally upgraded my blog with the latest version of BlogEngine.NET. This is a free, open source, implementation of an ASP.NET 2.0-3.5 blog. I was running v1.3 till now and have now upgraded to v1.5.07. There are a ton of new features in this release including new widgets, nested comments and more. I’ve implemented these features on the left column as you can see.

The theme that I use is called StarGazer created by Jason Lay. I’ve made massive modifications to this theme for my blog including:

  • Moving the right side column completely to the left using CSS. This is because I sometimes have code and images that flow across the page and in the case of a right side column would cause the layout to go for a toss.
  • Added the ability to use the first post as a Internet Explorer 8.0 WebSlice. This also requires a code change in the BlogEngine.NET core. I’ll be submitting this patch to the developers of BE soon.
  • Changed a bunch of ASPX layout to add the nested comments feature of v1.5 of BE.
  • Changed a huge bunch of CSS to get the styles correctly setup for different elements that didn’t even exist in the original theme but now appear due to structural changes in BE’s rendering.

For doing all this, it took me less than a couple of hours which included downloading, setting up and understanding the changes in BE1.5 on my local machine. I was greatly helped in the entire endeavor by Visual Studio 2008 and the Internet Explorer 8.0 Developer Toolbar. The latter was exceptionally useful in figuring out the classes and styles being used in any page and on the fly changing them to see what happens. Clearly a great tool to have for Web developers.

There are still some small changes that I need to do. The visitor info widget has a annoying icon that I want to get rid of and the Twitter widget doesn’t refresh automatically and the “Follow me” gives an error. I’ll need to look into this soon – but for now the blog is back up and running.

For anyone who is interested in the StarGazer theme, I’m putting it here to download:

UPDATE: I've now used a different Twitter widget called TwitterFeed. This allows a little more customization than the default one. Also, I made some changes in the styling by adding CSS classes for the date, feed and links shown in each Twitter.

Tags: , ,
Categories: ASP.NET | Internet | Personal | Rave

Actions: E-mail | Permalink | Comment RSSRSS comment feed

Charting in ASP.NET 3.5

Microsoft recently released a new set of chart controls for Windows and Web forms for .NET 3.5 SP1. However, to install and use them in Visual Studio you need to download and install a minimum of two different downloads and an optional third.

The first one is the main update for .NET 3.5SP1 available here. If you need Visual Studio 2008 SP1 support you need to install the add-on from here. If you need the full documentation, download and extract the file from here.

Once these are setup, you can add the Chart control from the Data group in the Toolbox. Add a data source, set the series data points in the properties and you are done. Quite easy to start creating dynamic charts on your site without any expensive 3rd party solution.

Tags: , ,
Categories: ASP.NET | Development | Rave

Actions: E-mail | Permalink | Comment RSSRSS comment feed

A week of super releases

Microsoft's development team has been quite busy lately. Last week we saw the release of SQL Server 2008 and this week we have the Visual Studio 2008 Service Pack 1 and .NET Framework 3.5 Service Pack 1 released as well. There are a whole bunch of things in this release:

  • Bunch of bug fixes
  • ASP.NET Dynamic Data
  • SQL Server 2008 RTM support
  • Entity Framework
  • IIS 7.0 managed module templates
  • Tons of more stuff...

You can read about the new features of VS2008SP1 and .NET 3.5 SP1 for more details. You might also want to install and run the Visual Studio 2008 Service Pack Preparation Tool to ensure that any old SP betas and hotfixes are removed correctly before attempting to install the RTM version of the service pack.

Tags: , , ,
Categories: ASP.NET | Development | Microsoft | Rave

Actions: E-mail | Permalink | Comment RSSRSS comment feed