Tuesday, February 21, 2012

ASP.NET MVC 4 Beta Features

The features of ASP.NET MVC 4 Beta are



  • ASP.NET Web API
  • Refreshed and modernized default project templates
  • New mobile project template
  • Many new features to support mobile apps
  • Recipes to customize code generation
  • Enhanced support for asynchronous methods

To know more please read the blog post from Scott Gu at http://weblogs.asp.net/scottgu/archive/2012/02/19/asp-net-mvc-4-beta.aspx


Hope this helps. Please do drop your comments.

Wednesday, February 15, 2012

Context Menu in Windows Phone 7


In this article we will look at how to implement Context Menu in Windows Phone. In order to implement Context Menu, we need to first download the SilverLight for Windows Phone Toolkit (November 2011) from http://silverlight.codeplex.com/ .

We need to reference “Microsoft.Phone.Controls.Toolkit” in the application. We will add the Context Menu to our earlier build application “ContactApp”. We will show it when the user clicks on the contact and it would show up as shown below




To invoke the context menu, we will write a method to create the instance of the context menu and add the menu items





Now we will invoke this method in the constructor the page. Then when we click on the listbox control and wait for a few seconds the context menu will appear.

Hope this was helpful. Please do drop your comments.

Tuesday, February 14, 2012

First Look at Launchers for Windows Phone


In this article we will look at the various Launchers available for Windows Phone. Launchers are nothing but enablers to perform common task enabling to provide a common user experience across the windows phone platform. This does not return any data.

The launchers available for Windows Phone are as follows



  • Bing Maps Direction Task
  • Bing Maps Task
  • Connection Settings Task
  • Email Compose Task
  • Marketplace Detail Task
  • Marketplace Hub Task
  • Marketplace Review Task
  • Marketplace Search Task
  • Media Player Launcher
  • Phone Call Task
  • Search Task
  • Share Link Task
  • Share Status Task
  • SMS Compose Task
  • Web Browser Task
In order to use these launchers, we have to reference the library

using Microsot.Phone.Tasks;


We will look at the following launchers and its usage

  • Phone Call Task
  • SMS Compose Task
  • Bing Map Task
In the earlier blog post, we had created a simple “ContactApp” application. We will add these launchers to them.

Phone Call Task

This task enables the users to make a phone call. From the “ContactApp”, we will see how a user can place a call when the user double taps the contact.

We will write the below code for the double tap event of the list item


From the above code, we see that the “Display Name” which is used to display name of the calling person and “Phone Number” which is the number to call properties of the “PhoneCallTask” class has to be set. After which the “Show” method is invoked to launch the task.

 The UI for the same is as shown below


Now when we click on the call button, the call is placed as shown below



SMS Compose Task

The SMS Compose Task helps enables the users to send SMS for the application. From the “ContactApp”, we will see how a user can Send SMS when clicking on the contacts

We will write a below code for a context menu item click event on “Send SMS” as show below


The UI for the context menu click is as shown below


Now in the new page “SendSMS.xaml”, we will add a “Send” button. For click event we will write the below code as shown



From the above code we see that we will set the “To” which holds the number of the receiver and “Body” which has the text message properties of the “SMSComposeTask” class. Then call the “Show” method to invoke the task.

The UI will look as shown below


On click of the “Send” Button, the below is seen


When we click on the above highlighted button,the sms will be send.

Bing Map Task

The Bing Map Task enables to launch the bing maps. For the “ContactApp”, we will see how to locate the contacts location.

We will write the below code for the context menu item’s “Search Location in Maps” click event 


From the above code, we see that the “Search Term” which accepts the searchable text on the map and the “ZoomLevel” which can be used to for setting zoom level properties of the “BingMapsTask” class has to be set. Then call the “Show” method to invoke the task.

The UI for the searched content, in this searched the location of contact “Los Angeles” is as shown below.


To read about other Launchers in Windows Phone, check out http://msdn.microsoft.com/en-us/library/ff769550(v=vs.92).aspx

Hope this was helpful. Please do drop your comments.


Tuesday, January 24, 2012

Isolated Storage Explorer for Windows Phone 7


In the previous blog post we had used the Isolated Storage for storing the data. We wondered how we can see the file or interact with the same. For this we have a tool called “Windows Phone 7 Isolated Storage Explorer”, this is a codeplex project.

We can download the same from http://wp7explorer.codeplex.com/ . The features are mentioned in the website.

In this article we will focus on how we can get this working along with the windows phone 7 applications.

Firstly, in the windows phone application we have to reference the “IsolatedStorageExplorer.dll”. This is available in your “< dir >\Program Files\WP7 Isolated Storage Explorer\Library”. 



Then we have to add the below code in the App.xaml file as mentioned below





Now we will launch the application and also open the explorer. It will look like as shown below




In the above screenshot, we can see the “Contact.txt” the file that was created for our “ContactApp”. We can view the contents of the same by downloading the file as shown below.




Hope this was helpful. Please do drop your comments.

Monday, January 23, 2012

Building a Simple Windows Phone 7 application


In this article, we will build a simple windows phone application. We have seen in the earlier blog post on the installation of windows phone SDK.

We will see how to create a simple application which will save the contacts on a windows phone.


Let’s begin by choosing the Windows Phone Application project as shown below





By default the “MainPage.xaml” file is created, we will modify the application title and page title as in the StackPanel as shown below





<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
      <TextBlock x:Name="ApplicationTitle" Text="Contact App" Style="{StaticResource PhoneTextNormalStyle}"/>
      <TextBlock x:Name="PageTitle" Text="My Contacts" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
StackPanel>

We will add the application icons add, delete and close button


We will add a Listbox which will display the contacts in the grid named “Content Panel”.
Lets create a simple contact class as shown below

    public class Contact
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string ContactNumber { get; set; }
        public string ContactType { get; set; }
    }

We will bind the contact class property to the listbox’s text blocks as show below


To save the contacts we will use the “IsolatedStorageFile”, this is an isolated storage area to save the data in their own file system. To know more about that read here http://msdn.microsoft.com/en-us/library/system.io.isolatedstorage.isolatedstoragefile.aspx

We will add the code in the page to create a storage file.

IsolatedStorageFile ISFile = IsolatedStorageFile.GetUserStoreForApplication();
string strFile = "Contact.txt";

We will now create a page “AddContacts.xaml” which will be used to add contacts. We will add 4 textboxes to accept the contact details as shown below


We will add two application icon buttons, one for save and another for close as shown below


Now we will add the code for saving the contact for the “Save” button’s click event as shown below


For the close button, we can add a click event and add the below code to navigate to the Main page


In the Main Page (MainPage.xaml), we will add the below code to load the contacts on the list box control


The “AddContacts” screen will be seen as shown below



The Main Page UI will be seen as shown below which will display the contacts




Hope this was helpful. Please do drop your comments.

Wednesday, January 18, 2012

Getting started with Windows Phone Development

If you are planning for development of apps for Windows phone, download the SDK 7.1 which has all tools needed for development from here http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=27570


Happy Coding...

Tuesday, January 17, 2012

Features of ASP.NET MVC 4 Developer Preview

The new features of ASP.NET MVC 4 Developer Preview as the release notes mentioned in http://www.asp.net/whitepapers/mvc4-release-notes is as follows

  • Enhancements to Default Project Templates
  • Mobile Project Template
  • Display Modes
  • jQuery Mobile, the View Switcher, and Browser Overriding
  • Recipes for Code Generation in Visual Studio
  • Task Support for Asynchronous Controllers
  • Azure SDK
  • Known Issues and Breaking Changes
To know more about these features check out at http://www.asp.net/whitepapers/mvc4-release-notes