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

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

Exchange Web Services & Sending Inline Images on Exchange 2007 SP1

Microsoft recently released the Exchange Web Services Managed API SDK 1.0. This mouthful which I’ll just call EWSMAS is useful for writing custom applications that work with Exchange Server (2007 SP1 or 2010). In one of the projects we are currently working on, we need to send emails over Exchange with both normal attachments as well as inline in the mail body.

Now here’s the good thing – if you’re already on Exchange 2010, there is a simple property called IsInline that will allow you to specify the attachment as inline. However, if you’re on Exchange 2007 SP1 still (like in the case of Exchange Online/BPOS), you’re stuck as the property returns an exception stating it’s only for Exchange 2010. Here’s how to solve this problem. Note that I’ve created a simple console app to demonstrate this method only. I assume you know how to download the SDK and add reference to it in VS2008/2010.

   1:  ExchangeService service = 
   2:       new ExchangeService(ExchangeVersion.Exchange2007_SP1);
   3:   
   4:  // Use when machine is IN Domain
   5:  //service.UseDefaultCredentials = true;
   6:  //service.AutodiscoverUrl("user@domain.com");
   7:   
   8:  // Use when machine is NOT in Domain
   9:  service.Credentials = new WebCredentials("user@domain.com", "password");
  10:  service.Url = new Uri("https://Your-CAS-Server/EWS/Exchange.asmx");
  11:   
  12:  // Create an e-mail message and identify the Exchange service.
  13:  EmailMessage message = new EmailMessage(service);
  14:   
  15:  // Add properties to the e-mail message.
  16:  message.Subject = "Testing from .NET Client";
  17:   
  18:  // Add the image as inline attachment
  19:  FileAttachment attachment = 
  20:       message.Attachments.AddFileAttachment("C:\\temp\\attach.png");
  21:  attachment.ContentId = "01"; // this should be unique - say a GUID
  22:   
  23:  // Add the message body which refers to this contentID
  24:  message.Body = "Sent from a .NET with inline image <img src='cid:01'>";
  25:  message.Body.BodyType = BodyType.HTML;
  26:   
  27:  // Add recipeint
  28:  message.ToRecipients.Add("anotheruser@domain.com");
  29:   
  30:  // Send the e-mail message and save a copy.
  31:  message.SendAndSaveCopy();

Notes:

  1. Lines 5-6 should be used when the machine sending the mail is in the same AD domain as the Exchange server (say, an in-house Exchange server)
  2. Lines 9-10 should be used when the machine sending the mail is in a different AD domain from the Exchange server (say, hosted Exchange or BPOS)
  3. Line 21 is the one that sets a ContentId property for the image attachment – this will now NOT show the image as an attachment anymore. In case you need to simply add it again – this time without the ContentId.
  4. Line 24 uses this ContentId with the cid: property in a standard HTML image tag. This is what makes the image show up inline in the right place.

Inline 
This is what the inline image looks like once it is sent and received.


Tags: , ,
Categories: Development | Microsoft | Exchange

3 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

Windows Phone 7 – My first app

As I unfortunately could not be at Mix 10 this year, I had to be content watching the Keynote from their live stream (which BTW worked flawlessly). Scott Guthrie as usual was outstanding and fun. And while showing off the new Windows Phone 7 developer tools went ahead and created a simple Twitter app on stage in about 5 minutes.

Well, I went ahead and downloaded the tools and installed them. Since I already had VS 2010 RC on my machine, it didn’t need to download the Express edition. It did install a bunch of other things and finally once done I went ahead and started it up.

So here’s how I beat ScottGu at his own game. I build a simple Twitter app for the Windows Phone 7 in even lesser time than him.

I created a Windows Phone application from the new project templates provided.WP7-01

Next, I changed some text around for the page and title. I also dropped in a TextBox, Button and a WebBrower control into the ContentGrid area on the phone.

WP7-02

WP7-03 I then simply added an event handler for the button’s click, like so:

webBrowser1.Navigate(new Uri("http://twitter.com/" + textBox1.Text));

That’s it. I then simply ran the application which started up the Windows Phone 7 emulator and deployed the application within it. Here’s what it looks like running.

The emulator doesn’t really have too many things in it other than Internet Explorer and some settings pages. You can of course go ahead and use the emulator to test out apps you create with Visual Studio 2010 or XNA Studio 4.0.

Here to creating great apps on Windows Phone 7. Have fun!


Tags: , ,
Categories: Development | Gadgets | Microsoft | Rave | SilverLight | Windows Phone

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

SharePoint 2010 Install Tips on Win08R2

It’s been ages since I’ve updated this blog. So let’s start the year with some install tips for one of the most exciting products coming out this year from Microsoft – SharePoint 2010.

If’ you haven’t got it yet, head over and download the SharePoint 2010 beta. If you are planning to install it for testing on a Windows Server 2008 R2 x64 machine here are some small install tips for you that’ll take some small irritations away from installing the beta.

  1. Download the Pre-Requisites for SharePoint 2010 beforehand and install them yourself. You can get a list of direct downloads for these at http://blogs.msdn.com/opal/archive/2009/10/25/sharepoint-2010-pre-requisites-download-links.aspx
  2. Make sure you’ve promoted the machine to a Domain Controller
  3. Once the install phase of the SharePoint setup is complete, do NOT start the SharePoint 2010 Product Configuration Wizard automatically. Instead, install the very important hotfix for .NET Framework 3.5SP1. Reboot after the install.
    • In case you did start the config wizard, you’d most probably have gotten an error on Step 5 while installing services. Quit the wizard and install the hotfix above.
    • Reboot the machine and open up RegEdit and search and delete all of the following (whichever you can find)
      • HKLM\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\WSS\Services\Microsoft.Office.Server.Search.Administration.SearchWebServiceManagerService
      • HKLM\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\WSS\ServiceProxies\Microsoft.Office.Server.Search.Administration.SearchWebServiceManagerServiceProxy
      • HKLM\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\WSS\Services\Microsoft.Office.Server.Search.Administration.SearchService
      • HKLM\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\WSS\Services\Microsoft.SharePoint.Search.Administration.SPSearchService
  4. Complete the install using the configuration wizard and you should be up and running with SharePoint 2010 easily enough.

Tags: , ,
Categories: Tips | Office | SharePoint

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

Our New Office

Nope, this is not about us installing a new build of MS Office 2010. We have moved our company office from Sushant Towers in Sector 56 to a new location. Our office address now is:

Enterprise InfoTech
311, 3rd Floor,
F-Block Market,
South City II,
Gurgaon, Haryana – 122002

We still have a lot of organizing and cleanup to do which should take most of today.


Tags:
Categories: Personal

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

Windows 7 vs. Snow Leopard on Gadget Guru

NDTV is probably India’s leading TV news channel with a bevy of different content channels. Gadget Guru is their extremely popular tech show that airs on NDTV Profit (the business channel) and NDTV 24x7 (the English news channel).

I was invited to be a panelist on a showdown between Windows 7 and Snow Leopard. The hosts – Vikram Chandra and Rajeev Makhni – each took one side (Mac OS and Win7 respectively). The panelists were Kishore Bhargava, Prasanto Kumar Roy and myself in front of a live audience.

The show was taped on Oct 20th and was great fun. You can’t imagine the amount of chaos surrounding an unscripted TV show. All of us had a good time and there was a lot of leg pulling on both sides. The show was broadcast on NDTV Profit on Oct 21st and will be re-telecast on NDTV 24x7 on Oct 25th at 6:30PM.

The telecast show had a lot of stuff edited out. Hopefully NDTV will release the other parts of the show on the Web. Till then you can catch an even more edited set of videos from this below (courtesy YouTube and Tubaah).

Snow Leopard vs. Windows 7: The Big fight
Audience Questions

Who's the winner? Windows 7 obviously!

Tags:
Categories: Windows 7

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

Using OpenType Font Features in Word 2010

We normally use what are called TrueType fonts on Windows machines for everything – whether in applications or when typing a document in Word. However, Windows Vista and above have had a new type of font system called OpenType.

OpenType is a scalable font format, built to be compatible with TrueType, but having many advanced typographic features like:

  • Ligatures
  • Numeric styling
  • Fraction Styling
  • Glyphs
  • Style “sets”
  • Contextual Alternates

You can read about the full specification of features here. However, the strange part has been that you couldn’t use the OpenType features in your Word documents… That is, till now. Word 2010 does have the ability to use the OpenType features in any document.

To do this, you will need to use an OpenType font. Some of these are Calibri, Cambria and the other “C”-fonts. But to really see the power of OpenType you need to use Gabriola. This is a script like font that has a number of cool features to it. Open Word 2010, change the font to Gabriola and add some text to the document. At first glance, the text looks pretty normal.

f1

Select the text and press <Ctrl>-D to enter the font properties dialog. Click on the Advanced tab to reach the OpenType settings. The easiest way to see the changes is to change the “Stylistic sets” value. Change it to say “5” for now and see what happens:

f2

You can now see that there are some nice effects starting to show up. Crank up the value to say 7.

f3

The text effects become even more pronounced. You can also experiment with the other settings to see other features of the font. For instance, the Number forms for “Lining” and “OldStyle” change how numbers are shown like this:

f4

f5The Contextual Alternates allow you to let characters change according to their relative position to other characters around them. Take a look at the “D” in the word “different” being typed below:

As you can see, the way that the character “d” is drawn changes each time surrounding characters change. You can turn this off or on if you want.

There are a ton of other features available in OpenType fonts as well and combinations of the settings can help you create extremely rich looking typography.

Do try out the OpenType features and with different fonts to see the effect of all the different settings you can do on them. You can add a ton of richness to your documents this way.

Here’s a small tip: If you’re using Outlook 2010, you can use these features when creating a new mail as well! f6


Tags: , , ,
Categories: Office | Rave | Tips

5 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