Application Page Ribbon & Dialogs on SharePoint 2010

One of the cool new features in SharePoint 2010 is the availability of the Office Ribbon. Using the simple XML syntax, it is quite easy to add your own Ribbon controls and tabs to existing lists, libraries, and even your own web parts. You can even add contextual ribbon tabs to web parts hosted in your own custom Application Pages.

Now it’s easy to get a “global” Ribbon by simply omitting the RegistrationId and RegistrationType attributes in the Elements.xml file. You’ll find ways of doing this in tons of blog posts all over. What is not so obvious, however, is the way to do add a Ribbon to a particular Application Page when the page does not host any Web part or user control. So here’s some help for you. I’ll also take a look at interacting with a modal dialog using the new framework in SharePoint from this ribbon.

More...


Tags: , , ,
Categories: Development | Office | SharePoint

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

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

1 Comments
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.

Usage

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.

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

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

7 Comments
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

12 Comments
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

4 Comments
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

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

Free LINQ E-book from Microsoft

You can download a full e-book on LINQ from Microsoft completely free from here. This is a great opportunity to start learning LINQ if you haven't already done so.


Tags: ,
Categories:

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

MIX it Up!

mix1Well, having (stupidly) missed the last couple of years' Mix's, this time I've decided to finally go. And Las Vegas is a place I've been wanting to visit but never been able to do so ever since my first trip to the US about 10 years back. If you're a developer, designer or anyone who has anything to do with creating content for the Web - this is the event to go to.

You can register and view the agenda of the sessions over at the Official Site. There are a bunch of cool stuff going over there as well. There is a great 20% discount currently on as well so get it while it lasts.


Tags: ,
Categories:

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

The Future of ASP.NET

aspThe Microsoft development team doesn't really seem to get a vacation, do they? After having just released Visual Studio 2008 which includes the .NET Framework 3.5, they're continuing to work on a ton of new things that are going to hit us soon.

  • ASP.NET 3.5 is part of the release and has a number of cool new things
  • My last post talked about the Silverlight 1.1 tools for VS08 being released
  • Silverlight 1.1 has now been renamed to Silverlight 2.0 due to the large number of features being added into it, including better and fuller support for WPF entities
  • The ASP.NET "Futures" stack has now been renamed to ASP.NET 3.5 Extensions and a preview release of this is expected soon in December. This will include the MVC Framework, Dynamic Data, REST and AJAX services

To paraphrase a Klingon saying, "It is a good year to develop".


Tags: ,
Categories:

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

ASP.NET Extensionless URL ReWriting in IIS 7

URL Rewriting is a method by which you can clean up the URL that is displayed to your Web site's users as well as do some SEO (Search Engine Optimization) on your site. So instead of having URLs like http://<server>/products.aspx?categoryid=123, you can create a URL that looks like http://<server>/products/books.aspx. Internally, this gets automatically mapped to the correct URL for you. ASP.NET allows you to do this quite easily. And there are a number of free URL Rewriting components that are available as well. The one that I've used and highly recommend is UrlRewriting.net. (There is another one - also free - called UrlRewriter.net but one that I've had not too great experiences with.)

To get UrlRewriting.net to work, simply copy the provided DLL into the ASP.NET site's /bin folder. Next open up Visual Studio for the site and edit Web.config as follows.

1. Add a <configSections> node to the main <configuration> part of the Web.config as follows:

<configSections>
<section name="urlrewritingnet" restartOnExternalChanges="true"
requirePermission="false"
type="UrlRewritingNet.Configuration.UrlRewriteSection, UrlRewritingNet.UrlRewriter" />
</configSections>

 

2. In <system.web>, add the following section:

<httpModules>
<add name="UrlRewriteModule" type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter" />
</httpModules>

 

3. In <system.webServer>, add the following:

<modules>
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule" />
</modules>

 

4. Create a new section, <urlrewritingnet> in which you'll add the "rules" for the rewriting. For example:

<urlrewritingnet rewriteOnlyVirtualUrls="true"
contextItemsPrefix="QueryString" defaultPage="default.aspx" xmlns="http://www.urlrewriting.net/schemas/config/2006/07" >
<rewrites>
<add name="GetProductCategories"
virtualUrl="^~/Categories/(.*).html"
rewriteUrlParameter="IncludeQueryStringForRewrite"
destinationUrl="~/ViewCategories.aspx?cid=$1"
ignoreCase="true" />
<add name="GetProduct"
virtualUrl="^~/Products/(.*).html"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/ViewProduct.aspx?pid=$1"
ignoreCase="true" />
</rewrites></urlrewritingnet>

 

The above example rewrites 2 sets of URLs: the first for getting categories (in the form: http://server/Categories/Books.html which redirects to http://server/ViewCategories.aspx?cid=Books) and the second for products (in the form: http://server/Products/au3yuad0494.html to http://server/ViewProduct.aspx?pid=au3yuad0494).

Now one of the biggest problems with this is that you cannot have extension-less rewriting in IIS. That is, a URL like http://server/categories/books is invalid as the final parameter doesn't have an extension. This is a bit of a problem and takes quite a bit of doing (writing an ISAPI filter) to get it to work on IIS 5/6.

The great thing is that IIS 7 (in Windows Vista and the upcoming Windows Server 2008) supports extensionless rewriting out of the box. All that you need to do is one small change in the Web.config shown above. In step 3, use the following instead:

 

<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule" /></modules>

 

The runAllManagedModulesForAllRequests="true" property ensures that all calls made to this site is processed through the ASP.NET 2.0 engine - including calls that do not have an extension. You can now go ahead and write your rules like this:

 

<urlrewritingnet rewriteOnlyVirtualUrls="true"
contextItemsPrefix="QueryString" defaultPage="default.aspx" xmlns="http://www.urlrewriting.net/schemas/config/2006/07" >
<rewrites>
<add name="GetProductCategories"
virtualUrl="^~/Categories/(.*)"
rewriteUrlParameter="IncludeQueryStringForRewrite"
destinationUrl="~/ViewCategories.aspx?cid=$1"
ignoreCase="true" />
<add name="GetProduct"
virtualUrl="^~/Products/(.*)"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/ViewProduct.aspx?pid=$1"
ignoreCase="true" />
</rewrites></urlrewritingnet>

 

In this case, there are no ".html" extensions for the URL and you can have valid ones like http://server/Categories/Books or http://server/Products/sadk442. Remember, this makes the structure of your site seem much more friendly to your user as well as get an additional benefit of being search engine friendly as well.


Tags: , ,
Categories:

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