Monday, November 22, 2010

HTML 5 Rocks!

Hello Guys,
HTML (Hyper Text Markup Language) is the base of NET based programing, we came across several version of HTML in past years, Now we are having the latest version of the HTML that is HTML5. Here are the Evolution of HTML

1991---- HTML
1994---- HTML 2
1996----- CSS 1 + JavaScript
1997 -------HTML 4
1998------ CSS 2
2000---- XHTML 1
2002 -----Tableless Web Design
2005 ------AJAX
2009------ HTML 5

As you all know that HTML 5 is going to rock the INTERNET World soon. The new HTML5 is the combination of the 3 powerful technology that are HTML, CSS & JS API that means

HTML5 = HTML + CSS + JS API

While Surfing on net for HTML5 I came across a very good site that is describing the new feature of HTML5 is a very good manner you can have a look at this site.


Please take a look and check the details and feature of the Rocking HTML5.

Thanks,
Anil Kumar Pandey
MVP (Visual C#)

Wednesday, November 10, 2010

Binding Silverlight DataGrid with XML file

Hello All,
In this article I would like to discuss about binding value to a Silver light DataGrid. As we know that there is no direct support for the Dataset or DataTable in the Silver light, so how can we bind the grid??? See there are multiple option for binding the grid in silver light either we can use the-
  1. 1. Collection of the Item Class,
  2. or a Dictionary or
  3. we can also use a XML File
In this article I am going to describe the way to bind a XML file that is present in the server Side, that means a User XML file can be bind to the grid in the Silver light form.Here I am Making use of LINQ to read the data from XMl file.


first We Will see that how can we access the XML file and its element. Please check the below Code.

private void getDatFromXML()
{
Uri newURL = new Uri("mydata.xml", UriKind.Relative);
WebClient cnt = new WebClient();
cnt.DownloadStringCompleted += new DownloadStringCompletedEventHandler(cnt_DownloadStringCompleted);
cnt.DownloadStringAsync(url);
}

Private void cnt_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
dataGrid1.ItemsSource = ReadListItem(e.Result);
}

public List<Item> ReadListItem(string xmlContent)
{
List<Item> il = new List<Item>();
XElement doc = XElement.Parse(xmlContent);
il = (from ele in doc.Elements()
select GetItem(ele)).ToList();
return il;
}

You have seen that how first we downloaded the file from the server machine and then reading its content to bind the Grid. Here ReadListItem is a generic function which returns us the LIST ITEM collection, the collection can be easily bind to the Silver light data grid. We just have to set the ItemSource property of the Silver Light Data Grid. like.

dataGrid1.ItemsSource = ReadListItem(e.Result);


I hope you have Got the Idea. Please look at the XAML part of the XML file that how the content looks.


<UserControl x:Class="DataBinding.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
d:DesignHeight="513" d:DesignWidth="662" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">

<Grid x:Name="LayoutRoot" Background="White" Height="600" Width="600">
<sdk:DataGrid AutoGenerateColumns="False" Height="200" HorizontalAlignment="Left" Margin="20,30,0,0" Name="dataGrid1" VerticalAlignment="Top"Width="450" />
</Grid>
</UserControl>


Hope You Understood the Way to bind the DataGrid in Silver light by a XML file. Please feel free to post the comments.

Thanks,
Anil Kumar Pandey
MVP (Visual C#)

Monday, November 8, 2010

New Features of Visual c# 4.0

Hello All,
One of my MVP friend has written a very beautiful articles on the latest features of the Visual C# 4.0. I would like to share with you, Please follow the below link and read this article. I hope you will like that.


Hope you will like this.


Thanks & Regards,
Anil Kumar Pandey
MVP Visual C#

Kontera