Friday, May 30, 2008

Microsoft Innovation Days at Kochi

I attended the Microsoft Innovation Days event at Le Meridien Hotel, Kochi today. Innovation Days are day-long free events filled with technical and business sessions, during which one can learn about the Microsoft technology roadmap and are introduced to upcoming technologies. Microsoft also presents Partner Programs and benefits for ISV partners.

This year the event series in India started on 16-May-2008 at Chennai and is concluding at Pune on 02-Jun-2008. Besides Cochin, Ahmedabad is the only other city to host this event. One source from Microsoft indicated that the big cities like Bangalore, Mumbai and Delhi are getting 'abused' by events and the number of no-shows after signing up is increasing. That made them to choose Tier-II cities in India for such events where they are getting a very good response.


The day here started with a session by Nahas Mohammed on 'Building Rich Internet Applications Using Silverlight 2.0'. At the end of it, my colleague Jim Mangaly did a great presentation showcasing 'Lithium', a virtual vehicle gallery and showroom application developed in Silverlight. He explained how various awesome technologies in Silverlight were taken to full advantage for the development of this application. The 200 plus technology enthusiasts in town were quiet impressed with the presentation. Since our company IdentityMine is mostly focusing on US market, we are not so well known here. But the participation in events like this are slowly changing the scene.

The next session 'Building high performance .NET applications' by Harish Ranganathan focused on tips and tricks to make .NET applications perform better. He also did a demo of 'ASP.NET Dynamic Data' which is part of '.NET Framework 3.5 Service Pack 1 Beta'. It was scary to see him build a web site to manage all the data operations (add/edit/delete) for all the tables in a database just by pointing to a LINQ to SQL data context. The wizard created website was complete with proper navigation and validation.


After a heavy and delicious lunch, there were two more interesting sessions named 'LINQ: Working with data naturally!' and 'Getting the Best from SQL Box: Performance Tuning SQL Server'.

Microsoft also announced their partner program called Innovate On for Kochi. They distributed a lot of goodies for the early birds and for the question askers.

Wednesday, May 07, 2008

WPF Color Pad

Ever wanted to see the list of named colors available in WPF's System.Windows.Media.Colors? And fancied using it's hexa code to get the colors like 'Tomato' in your web page?

Here is a simple WPF Application called ColorPad that lists out all the named colors. Click on a color to see its hexa code value. Remember to remove the first two letters/digits that represents the transparency (Alpha value) if you are using this color in html pages.


The application can be downloaded from here.

The XAML Source Code:

<Window x:Class="ColorPad.Window1" Icon="ColorPad.ico"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="ColorPad" Height="500" Width="300" WindowStyle="SingleBorderWindow" ResizeMode="NoResize">
<Window.Resources>
<DataTemplate x:Key="tempGrid">
<Rectangle Width="60" Height="20" Fill="{Binding Name}" Stroke="#FF000000"/>
</DataTemplate>
</Window.Resources>

<Grid x:Name="LayoutRoot" ShowGridLines="True">
<StackPanel Orientation="Vertical">
<TextBlock x:Name="uxTitle" Text="ColorPad Version 1.0.0" Width="210" TextAlignment="Center" />
<ListView Height="400" Width="210" Name="uxColorGrid">
<ListView.View>
<GridView x:Name="uxColorGridView">
<GridViewColumn Header="Color Name" DisplayMemberBinding="{Binding Path=Name}" />
<GridViewColumn CellTemplate="{DynamicResource tempGrid}" Header="Color" />
</GridView>
</ListView.View>
</ListView>
<TextBlock x:Name="uxFooter" Visibility="Collapsed" Width="200" Background="{Binding RelativeSource={RelativeSource Self}, Path=Text}" />
<TextBox x:Name="uxColorCode" Width="210" TextAlignment="Center" />
</StackPanel>
</Grid>
</Window>


And the Code Behind in C#:

using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Collections.Generic;

namespace ColorPad
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();

uxColorGrid.ItemsSource = typeof(Colors).GetProperties();
uxColorGrid.SelectionChanged += new SelectionChangedEventHandler(uxColorGrid_SelectionChanged);
}

void uxColorGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
PropertyInfo c = uxColorGrid.SelectedItem as PropertyInfo;
uxFooter.Text = c.Name;

SolidColorBrush scb = uxFooter.Background as SolidColorBrush;
uxColorCode.Text = scb.Color.ToString();
uxTitle.Foreground = uxFooter.Background;
}
}
}

Monday, May 05, 2008

ASP.NET 3.5

My last two major projects were in ASP.NET 2.0. That was just few months back. Now I am getting swamped in the .NET 3.5 world with WPF, Silverlight and LINQ and was bit worried when I had to consider ASP.NET as an option for a new project. By all chance, few months is longer than enough for Microsoft to flood us with new technologies and I was almost sure the new ASP.NET 3.5 will yet again look like an odd world for me.

But that was not the case. As with the .NET framework, the ASP.NET 3.5 is a set of additive features on top of ASP.NET 2.0. Most of the things I have learned in .NET 3.5 like the cool new C# features (LINQ, Query Expressions, Lambda Expressions, Type Inferencing (var), Class and Collection Initializers, Anonymous Types, Extension Methods) are useful in the web development world too. Moreover the new Visual Studio 2008 features (improved web page designer, css editing, javascript intellisense and debug support) are also much helpful for web developer.

Besides that there are very few ASP.NET specific new features. That includes ListView Control, DataPager control, and the integrated ASP.NET AJAX support.

ListView control is a beautiful data web control that can be bound to multiple records (like a grid) but still allows flexible layout. The DataPager only works with ListView Control and provides a paging user interface - next, previous, first, last buttons, for example.

AJAX support was earlier available in ASP.NET 2.0 as a separate download. Now it is part of ASP.NET 3.5. But if we want more AJAX controls, we still need to download the AJAX Control Tool Kit. You can unzip the contents to your computer (Somewhere like C:\Program Files\AjaxControlToolKit) and add them to Visual Studio. Make sure that the AjaxControlToolkit.dll is available in the Binaries folder. If not, you can either build the solution or copy it from the SampleWebSite's bin folder. By right clicking on the Toolbox in Visual Studio 2008, you can Add a new Tab and then Choose Items to browse for AjaxControlToolkit.dll to add all the AJAX controls into the tool box.

I did a sample AJAX website in few minutes. As usual start a new 'ASP.NET Web Application' project and make sure the target version of .NET Framework is 3.5. First we need to add the 'ScriptManager' and 'UpdatePanel' controls from AJAX Extensions tab in Toolbox and then we can add the controls to this panel. Try adding a Text Box, a Button, and a Label. On the designer, double click on the button to get the click event handler in the code behind. Change the label text to display something. (Label1.Text = "Hello " + TextBox1.Text;).



On the designer, an adorner appears on the supported controls and it can be used to add AJAX extenders. I tried adding a Confirmation Button Extender for the button and all I had to write was the ConfirmationText for this extender.

<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
<cc1:ConfirmButtonExtender ID="Button1_ConfirmButtonExtender" runat="server"
ConfirmText="Are you sure?" Enabled="True" TargetControlID="Button1">
</cc1:ConfirmButtonExtender>

On running the application, a confirmation message box will appear while clicking this button, and the click event will be fired only after user confirmation. All this code will run at client side and the beauty is that I didn't write a single line of javascript.

Try adding PasswordStrength and DropShadowText extenders for the text box and have fun exploring more.