July 2010 - Posts

On July 6, “His Highness Gu” – well wondering who is this – none other than Scott Guthrie of Microsoft. I like to address him as “His Highness Gu” after going through Scott Hanselmans’ (Principal Program Manager, MS) this video. So on July 6 Scott blogged about a new tool that was released which is known as “WebMatrix”. WebMatrix is a lightweight web development tool that integrates 3 new web development technology such as:

So i too jumped into the band wagon of users who started to check out the new tool. Must say its so light weight but keeps you the full power to build great looking sites in just couple of hours. Not only that it has some cool starter example sites – namely – Bakery, Photo album etc. These examples have all the code you need to just copy & paste and finish up a site.

Now, as they say – “Necessity is the mother of invention” – i am going to talk about an aspect till now nobody has blogged about (as far as i know). I started to play around with WebMatrix by creating a site of my own. No this was not a example site – rather – i am trying to build something for the community. Will spill more beans may be in one of the coming blogs. So in the course of building this site i started looking at different aspects of the WebMatrix. I was working on user creation module and as any user registration has, i too have an email field. As i said there is a example site bundled with WebMatrix known as “StarterSite” which by the way is an excellent code example of a full fledged site with security around it. So i too looked at that example. In the registration page processing – the code was checking only if the email field was empty or not. If empty it was not valid. Check the code below:

   1:   // Validate the user's email address
   2:          if (email.IsEmpty()) 
   3:          {
   4:              emailErrorMessage = "You must specify an email address.";
   5:              isValid = false;
   6:          }

As you can see there is no check for the valid format. So this is where i started to see how can i add my code to check for the valid format. The first thing that comes to any developer with a decades experience in the field is how about a regular expression. True isn't it. So next question was how do i use regex in WebMatrix. Again i Google/Binged about the keywords “WebMatrix and Regular Expressions” to see if anybody else has had the same thoughts as of me. But didn't get the required search results. So i started to play around with  the code.

As the WebMatrix documentation says, Razor is just a view engine for the ASP.NET web page development. So i can reap any .NET based feature from WebMatrix too. WebMatrix is just giving a new way of coding an ASP.NET web page using a new view engine code named Razor. If you are wondering why the name Razor – i think its my analogy to say that – with this new templating format and engine the syntax to code a mark up and server side code is extremely fast. So we all know that Razor are known to be sharp and perform their work faster. Its just my thought.

Coming to the code, what i was thinking here was – i am already in .NET, coding a server side piece of code block. So shouldn't it support any C# object. Well a noble thought. So spun up a little piece of code to see if i was right. I had  the following piece of code added in the page now. I just tried to instantiate a Regular Expression object as below:

   1:  // Validate the user's email address
   2:          if (email.IsEmpty()) {
   3:              emailErrorMessage = "You must specify an email address.";
   4:              isValid = false;
   5:          }
   6:          var pattern = “<pattern>”;
   7:          var regEx = new Regex(pattern);


For those of you wondering how a Razor file looks like – here is the screen shot of the Register.cshtml. By the way CSHTML is the new file extension to let the framework know that it has to use Razor templating engine for parsing:

image
Now here is the output of the above page:
image

Well what can i say – its our very own familiar Yellow Screen Of Death. So what happened. If you look at the error message – it is saying me that it cannot find the object Regex and asking me if i have missed to put any references by putting “USING” directive. Now this is really something i didn’t expect – “are you missing a using directive”. If you notice the Register.cshtml file above – in Razor so far all the examples i have seen – nobody has shown a code piece using the “USING” directive. Well then i am might be the first one to dig this out. Another interesting thing i noticed was – look at the bottom of the page. It has 2 sections – “Show Detailed Compiler Output” and “Show Complete Compilation Source”. What – show complete compilation source – Eureka Eureka – only that i was not in a bath tub but on a chair : ). That's what i want to know – what did the compiler compile my page as. Great. So here is what the compilation source of my Register.cshtml looked like:

Line 2:    //------------------------------------------------------------------------------
Line 3:    // <auto-generated>
Line 4:    //     This code was generated by a tool.
Line 5:    //     Runtime Version:4.0.30319.1
Line 6:    //
Line 7:    //     Changes to this file may cause incorrect behavior and will be lost if
Line 8:    //     the code is regenerated.
Line 9:    // </auto-generated>
Line 10:   //------------------------------------------------------------------------------
Line 11:   
Line 12:   namespace ASP {
Line 13:       using System;
Line 14:       using System.Collections.Generic;
Line 15:       using System.IO;
Line 16:       using System.Linq;
Line 17:       using System.Net;
Line 18:       using System.Web;
Line 19:       using System.Web.Mvc;
Line 20:       using System.Web.Mvc.Html;
Line 21:       using System.Web.Security;
Line 22:       using System.Web.UI;
Line 23:       using Microsoft.Data;
Line 24:       using Microsoft.WebPages;
Line 25:       using Microsoft.WebPages.Helpers;
Line 26:       using System.Configuration.Provider;
Line 27:       
Line 28:       
Line 29:       public class Register_cshtml : Microsoft.WebPages.WebPage {
Line 30:           
Line 31:       protected Microsoft.WebPages.WebPageHttpApplication 
               ApplicationInstance {
Line 32:               get {
Line 33:                   return ((Microsoft.WebPages.WebPageHttpApplication)
                                   (this.Context.ApplicationInstance));
Line 34:               }
Line 35:           }
Line 36:           
Line 37:           public override void Execute() {
Line 38:               
Line 39:               #line 1 "C:\Users\kashyapa\Documents\My Web Sites\Starter Site\Account\Register.cshtml"
Line 40:   
Line 41:       // Set the layout page and page title
Line 42:       LayoutPage = "~/_SiteLayout.cshtml";
Line 43:       PageData["Title"] = "Register an Account";
Line 44:   
Line 45:       // Initialize general page variables
Line 46:       var email = "";
Line 47:       var password = "";
Line 48:       var confirmPassword = "";
Line 49:       
Line 50:       // Validation
Line 51:       var isValid = true;
Line 52:       var emailErrorMessage = "";
Line 53:       var passwordErrorMessage = "";
Line 54:       var confirmPasswordMessage = "";
Line 55:       var accountCreationErrorMessage = "";
Line 56:       // var captchaMessage = "";
Line 57:   
Line 58:       // If this is a POST request, validate and process data
Line 59:       if (IsPost) {
Line 60:           email = Request.Form["email"];
Line 61:           password = Request.Form["password"];
Line 62:           confirmPassword = Request.Form["confirmPassword"];
Line 63:           
Line 64:           // Validate the user's captcha answer
Line 65:           // if (!ReCaptcha.Validate("PRIVATE_KEY")) {
Line 66:           //     captchaMessage = "Captcha response was not correct";
Line 67:           //     isValid = false;
Line 68:           // }
Line 69:           
Line 70:           // Validate the user's email address
Line 71:           if (email.IsEmpty()) {
Line 72:               emailErrorMessage = "You must specify an email address.";
Line 73:               isValid = false;
Line 74:           }
Line 75:           var pattern = “<pattern>”;
Line 76:           var regEx = new Regex(pattern);     

As you can see this is nothing new. Same as what you would expect in ASP.NET page. Now coming back to my problem – why isn't Regex recognised as object. Because – take a close look at the using directive sections. There is no “System.Text.RegularExpressions” namespace added. So compiler promptly told me hey i can’t find the object. So far so good. Now all i have to figure out is how do i add a using statement inside a Razor  template. What i did was i added using as below:

@{    
      using System.Text.RegularExpressions;        
 
     // Set the layout page and page title    
    LayoutPage = "~/_SiteLayout.cshtml";    
    PageData["Title"] = "Register an Account";

Notice that i have added the using statement at the top of the page. I am expecting this is gonna work. Lets see what happened when i ran in the browser:

image

Oops – again a Yellow Screen of Death. But this time – with loads of information. What it told me was :

Namespace imports and type aliases cannot be placed within code blocks.  
They must immediately follow a '@' within markup.
It is recommended that you put them at the top of your page,
as in the example below:
 
@using System.Drawing;
@{
   // Now you can use types from System.Drawing throughout your page
}

Boom there you go. Thanks Microsoft. Without any documentation i was able to figure out what’s the usage with just the error messages. Great debugging i must say. Just kidding. So all you need to do is place the using statements as the first lines of code which should be immediately followed by “@” sign. So i modified the code as below:

@using System.Text.RegularExpressions;
 
@{
    // Set the layout page and page title
    LayoutPage = "~/_SiteLayout.cshtml";
    PageData["Title"] = "Register an Account";
    
    var pattern = "<pattern>";
    var regExp = new Regex(pattern);

 

As soon as modified with code with above statements – i got the page rendered without any problem.

As you can see every problem has a solution one way or the other. I just wanted to share my experience here. So created this blog post.

Summary:

Using directive can be used in the Razor template files. They need to be the first statements to be placed in the file and should be immediately followed by “@” symbol. This gives me a lot of exploration points.

Line of thought:

I am not sure if the “Show Complete Compilation Source” link will be present even in the production environment whenever a yellow screen of death comes up. I am running the WebMatrix beta which comes with SQL CE and IIS Express. What’s good about this feature is that i can know what the compiler did. But at the same time if this is the behavior even in the production environment then this is gonna expose all the “MAGIC STRINGS” that we developers do use in our codes all the times and some of them may be sensitive information. I am not the best person to comment on this. May be if “His Highness Gu” has time to go through my article, only he can anser this.

As always, till next Happy Coding. Code with passion.

 

Technorati Tags:
    
del.icio.us Tags:

I have been doing community speaking lately. Last 2 weeks i have done 2 sessions as part of the community launch events of “Office 2010”. One was in Mysore along with www.MysoreGeeks.com and another was at Bangalore along with www.BDotNet.in. Both experiences were great for me since these were the first community speaking of my life.

While preparing for the session on “Ribbon Customization for End Users” i did scout for information on the internet. Especially went through many pages on Microsoft ecology i.e. MSDN, TechNet, MSDN blogs etc. What i found were some interesting content.

First and the foremost – i have to talk about the following blog post. This was a blog post from the Microsoft Office 2010 Engineering Team. This is on the Technet Blogs. Here is the link – “Making the Ribbon Mine”. An excellent blog post way back in Nov 2009 by the team. This kind of laid out the whole presentation of mine. I wanted to address my presentation from the perspective of “What, Why and How” and the blog post just laid out the same perspectives. Its always great to tell something with respect to a story – this makes the audience easy to relate to what i am talking about. This blog post was an excellent writing for me and gave me all the aspects of the things i should cover about. Also it made to understand that Microsoft is trying to push the customization of Office 2010 Ribbon with a new phrase – “Making the Ribbon Mine”. Interesting usage of words here. Observe that when we say Customization – it looks more technical. When we are talking about end users its more of office users who do not have any technical background. Of course even a techie is a end users but its just that he understands what a customization is. So instead of telling customization we are saying make it yours – Make the Ribbon Mine. I kind of like the idea of reaching out to the non techies. My two sessions were based on this content. So i thank the Office engineering team for such an excellent post.

The above blog post i mentioned is more of a primer to anybody. So i started searching if there is any content out of office site which will give you a step by step instruction for end users to achieve the customization. What i found out was this excellent help content both textual and video based.

  • Customize the Ribbon

    • This help content is like a step by step guide to any body – be it a techie or a non techie. Its a true help document because at the starting of the content you get a question – “What Do You Want To Do”. So from there on wards it takes you through the following pointers:

      • Download free customized Ribbons

      • Get to Customize Ribbon Window

      • Working with Tabs

      • Working with Groups

      • Working with Command

      • Reset the Ribbon

      • Export customization

      • Import customization

So an excellent source of customization help content.

  • Video: Customize the Ribbon

    • This help content is very similar to the one described above – the textual help content – but only difference is as the name says this has video describing how to do it Smile. So this will give anybody a way to easily do what they want to do since they have visuals to support. Personally i felt excellent concept. I am not sure if we had video based help content for any of the office applications before this. May be i am ignorant of any such content. But this one i really liked it. Way to go Microsoft. This help content also starts with “Watch what you can do to customize the ribbon”. Just look at the wording. Since this is a video based content – the keyword “Watch” has been used Smile. Nice. So you have the following help topics in this content":
      • Choosing Commands
      • Changing default tab
         
      • Creating your own tab
      • Hiding a tab
      • Sharing the ribbon customizations

All the videos are clear and crisp in the content. They tell you exactly what you need to do. No messing around unnecessary things, its right up to the point.

Well that was my take on the help contents available for the Office 2010 Ribbon Customizations for the end users. Of course for the techies there are ways to customize the ribbons programmatically. May be that will be another blog post in future.

Till next time Happy coding. Code with passion.

Technorati Tags:
   
del.icio.us Tags:

******Update - Posted the links to pictures of the event ******  

Last weekend i.e. Jul 3, I was asked to present my session at Office 2010 Community Launch Event in Bangalore. This was in association with www.BDotNet.in. BDotNet is one of the largest and active .NET User Group in India. I was happy that i got one more chance. Thanks to Pavanaja/Kashi/Vic for this opportunity.

I was happy to present at Bangalore because Bangalore is a bigger ground when it comes to Technology. Bangalore is the Silicon Valley of India. So i readily agreed thinking that this will be the real test of my nerves. Also another point was – the Bangalore event was held at the Microsoft campus. So i thought this is a chance to say that i visited MS campus.

On the day of the event i was actually late by 10 minutes. Vic and Kashi of BDotNet were already present at the hall. When i entered i was told that the first speaker Mr. Arun Kumar who was supposed to take up a session on SharePoint 2010 was not able to present his session as he was hospitalized. And Pavanaja was on his way – he was in the campus trying to find parking at that time. Since he was to handle the second session, he thought he will have his slot at 3. So at this moment i saw about 15 community members who had come to the event. I must say at this point that i was expecting a bigger crowd. Well it was a fine Saturday here in Bangalore. So thought that not all are Geeks like some of us : ).

Vic and Kashi asked me if i could fill the gap by showing some things. The only thing i could have done is to show Office 2010 to the audience. But Pavanaja had a 1 hour slot completely dedicated to that. He was to talk about new things that are available in Office 2010 from an end user perspective. So i had to be careful not to spill the beans. So i thought i just show them some of the following concepts:

- All Office 2010 application now have a cool Splash Screen added. Prior to Office 2010 – if the loading of an application lets say Word/Excel/etc took time to load you didnt have a visual cue for the same. Now you will see a splash screen which looks like below:

image

(Source : http://blogs.technet.com/b/office2010/archive/2009/12/11/office-2010-visuals-and-branding.aspx)

- Back Stage View – This is the new concept that all Office applications have. The big button on the top left hand corner that was seen in Office 2007 is gone. Instead it is replaced by the “File” tab. The back stage view is used to perform action outside of the document and not within the document i.e. you can do actions like “Save”, “Save As”, “Set Permissions” etc… I hope you got the idea. Following is the screen shot of the back stage view:

image

So i took about 20 minutes going through the above features. Explained them the different things available in back stage view and did some hand on demo on the back stage view.

When i was done with the brief intro of Office 2010, Kashi/Vic asked me if i could start my session. My session was programmed to be held next to Pavanajas session – because – his session would have explained what is Office 2010. Then i will pitch in with how as an end users can customize things in office. But since Pavanaja had not yet arrived at the hall i went ahead with the show.

I had revamped my whole slide decks from those used for Mysore. I changed only the UI and had kept the content as is. I used the template known as “Duarte”. If you have Office 2010 – then you must watch the presentation template titled “Duarte”. Excellent concepts of how to do a stunning presentations. So i picked this one up and re did the whole slide deck. Put in some of the cool new transitions and animations available in 2010.

My session as a whole went on well. I could see many people nodding there heads for some of the points i made. I could also interact with them once they started to feel comfortable. I did get some questions and i was confident enough to give them a convincing answer. Somebody tweeted saying my slide deck and transition were very good (Hash tag for the event was #myoffice2010). Now that’s really a booster for you to carry on the show. When you put in effort and you get at least one appreciation means a lot. I have uploaded the slide decks used in  my previous blog post. So check that out and let me know your comments.

All in all i could say that this experience was very good for me. I am gaining confidence in each session i am giving. I am looking forward to many more of these talks. It was nice to meet Kashi and Vic from this event. Also met couple of twitter friends like Raj (@Raj2s), Shyam (@brandbull), Ninaada (@Ninaada). Nice meeting you all guys.

Another news from my side will be - If all goes well, i will be getting a chance to speak at a much more bigger podium than my first 2 sessions. Will have more on this in days to come.

****Here is the links to the photos of the event:

BDotNet.in link
Dr. U. B. Pavanajas photos of the event

Till then, Happy coding. Code with passion.

del.icio.us Tags:
     
Technorati Tags:

I have finished 2 presentation session within 2 weeks time frame. Yes, if you have been reading my blog you will know that i presented the following session -

I have uploaded the slide decks used for both the talks in the slide share. Here is the slide share embedded here within the blog. You can always get on to the slide share and download a copy. The slides have been done using PowerPoint 2010. Slide Share would have removed all the transitions and animations when we upload. If you download the .PPTX file and have Office 2010 you will see some cool effects. If you don’t have Office 2010 you can always open in previous version but they may not be able to show all the new transitions and animations. I have also uploaded a .PPS file juts in case. The PPS is in 97-2003 format. So it does not have the transition and animations of 2010.

Go through the slides. Unfortunately i do not have the speaker notes added in the presentation. May be i will try to add and upload again. Let me know your comments on how you felt about the slides. Please leave a comment. Feedback is the only way i can better myself.

Till next time – Happy coding. Code with passion.

 

Technorati Tags:
     
del.icio.us Tags:

I am back with another post this week. I think this has been the most happening blog week for me.

If you have been a regular reader of my blog, then you would have read about my first presentation at Mysore UG on Jun 27. Now i have a invitation to speak at one more User Group. This time its in Bangalore.

BDOTNET which is one of the largest and most active Microsoft  User Group in India is having a Community launch Event of Office 2010. I have invitation from BDOTNET to give a session on “Office 2010 Ribbon Customization”. I am glad that i have this opportunity – because – this will be a bigger audience than Mysore. So this will be a real test of my nerves :).

Another interesting thing this time is, I will be sharing the stage with Mr. Michael S. Kaplan. Mr. Kaplan is working at MS Redmond. He is the Guru of Internationalization. So i am thrilled see him in person. If possible hope to get a snap with him. Here is Mr. Kaplan blog - http://blogs.msdn.com/b/michkap/.

Here is the invite to the Event @ Bangalore. Please do make it and hope to catch up with you there.

O2K10_Blr_ComLaunch

del.icio.us Tags:
     
Technorati Tags:

I just wanted to write my experience of the first ever presentation i made as a Speaker in one of the local technology group. So here it is.

On June 27 www.MysoreGeeks.com along with www.MeraWindows.com scheduled what is known as Community Launch Event. This time we were doing the community launch event of Office 2010. Thanks to Dr. U. B. Pavanaja for giving me a chance and a slot to speak at the event.

I took nearly 1 week to have my slide deck prepared. I went through almost 3 to 4 templates within this time. I would take up one template put all the content – play around with the animations and transitions – must say 2010 has a lot more of cool animations and transitions. When i would go through the whole slide deck i would say – naah lets check another template. So this went on for nearly with another 3 to 4 templates. Finally i settled down for a template – keeping in mind that – people would be interested in what i speak and how i present than how my template looks.

On the day of the event, was present at the venue i think 45 minutes early. The event took place @ “Center for Management Studies” block in SJCE – Sri Jaya Chamarajendra College of Engg. Mysore. SJCE happens to be my college meaning i graduated from this college 10 years ago. Yup in Aug 2000 – i passed my Bachelors of Engineering in Industrial & Production. Wondering how come a production engineer ended up into software industry – well i had a computer language in my curriculum called – FORTRAN. Does any body remember FORmula TRANslation any more. Well i was fascinated by this and ended up learning JAVA and Active Server Pages (ASP) and eventually end up in .NET technology. So when i walked through the campus again after 10 years it was some emotion going through me.

Now back to the event – the auditorium where i was to deliver my first presentation was an excellent place. When i reached the place only the  organizers were there. So the whole hall was empty. I took a moment to make myself accustomed to the environment. I have never done a public speaking before this day. I used to occasionally present couple of things in front of my team – that’s it. But this was much more than that. Since this being my first ever presentation i wanted to be perfect. So i hooked my laptop to the projection system and did a quick dry run myself. I must say i did have a jinx at that moment. Was nervous too.

Once i had done all my setup and dry runs – it was time to see how many people turn up to the event. Myself and Dr. U. B. Pavanaja had tweeted a lot on the twitter and posted it on the Facebook and stuff. But we didn’t get the expected audience. There were totally around 15 people who came for the event. We were happy that at least we had that many :).

First to present was Pavanaja. He took the session on What’s new in Office 2010 from the perspective of Word/Excel/PowerPoint. He did have a colorful slide deck with all the new transition that PowerPoint 2010 supports. It was fun to listen to him and his hands on demo.

Second speaker of the day was Mr. Renuka Prasad from Tech Mahindra. He took a session on OneNote 2010.

The last session of the day was mine. My session was on “Office 2010 Ribbon Customization – for end users”. I was trying to address the forte of how an end user i.e. one who uses office to just create documents and read documents – how they can customize the ribbon according to their needs. Prior to Office 2010 the customization of Ribbon was a developmental effort/solution. It was not something an end user could have done it with some mouse clicks. With Office 2010 the customization is just few clicks away. I must say that the whole presentation of mine went very well. Luckily i gained confidence as i went into the presentation. I was able to speak out all the things i had imagined i would say during the talk. So all is well that ends well.

I must thank the Office Team for the content to my presentation. They have an excellent article titled “Make the Ribbon Mine”. You can find it here. That’s the best article i could figure out pertaining to this area. So thanks Office Team.

The photos of the event are present at the following location:

Office 2010 - Mysore Community Launch Event

Mysore Geeks - Office 2010 community launch

I also have recorder my whole session. It needs some cleaning up and compression things to be done before i upload it to web. Will upload in a couple of days time and update the post. Also the slide decks will be uploaded.

Do let me know your comments suggestion or whatever you have :). it will help me to shape myself for further presentation.

Till next time, happy coding. Code with passion.

Adios…

Technorati Tags:
  
del.icio.us Tags:
More Posts