Mar 29 2008

Ready-Made Delegates in .NET 2.0

Category:[email protected] @ 22:31

Sometimes while writing your code you need to create new delegates to meet your specific project requirements to call specific methods. Before directly opening a new CS or VB class and start adding new delegates, make sure to check the read-made delegates introduced by .NET 2.0. Some of these are listed here:


.NET 2.0 Read-Made Delegates

1. delegate Boolean Predicate<T>(T obj);

This is a delegate that can hold a reference to a method that takes as input a parameter of type T and returns boolean.


2. delegate void Action<T>(T obj);

This is a delegate that can hold a reference to a method that takes as input a parameter of type T and returns nothing.


3. delegate void MethodInvoker();

This is a delegate that can hold a reference to a method that takes no input parameters and returns nothing.


In .NET 3.5 new delegates were added:

delegate void Action();

delegate void Action<T1, T2>(T1 arg1, T2 arg2);

delegate void Action<T1, T2, T3>(T1 arg1, T2 arg2);

delegate void Action<T1, T2, T3, T4>(T1 arg1, T2 arg2,T3 arg3, T4 arg4);

delegate TResult Func<TResult>();

delegate TResult Func<T, TResult>(T arg);

delegate TResult Func<T1, T2, TResult>(T1 arg1, T2 arg2);

delegate TResult Func<T1, T2, T3, TResult>(T1 arg1, T2 arg2);

delegate TResult Func<T1, T2, T3, T4, TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4);


The above delegates are self explained. So now, when you need a new delegate, check the existing ones before creating your own! The above delegates are all present inside the System namespace.


Hope this helps,


Mar 28 2008

Microsoft - LebDev Visual Studio and Windows Server 2008 Community Launch

Category:[email protected] @ 21:54

Today we had the LebDev user group version of the Community Launch for Visual Studio 2008 and Windows Server 2008 at the Gefinor - Rotana Hotel - Hamra. The session started at 6 and lasted for 3 hours.

Maral Topalian delivered a session on Windows Server 2008

I presented a demo-ish session by developing a simple blog engine using LINQ to SQL, AJAX, ASP.NET 3.5, VS 2008. You can download the PPTX and code from here: Presentation ( and Sample code(

Wessam Zeidan ( then delivered another demo-ish presentation on Silverlight 2.0, WPF, and ADO.NET Data Services.

The next stop is the official Microsoft Launch on April 30! I will be delivering something, not sure yet what it is :)


Hope this helps,


Mar 27 2008

Intellisense with Client-side Proxy Classes in AJAX

Category:[email protected] @ 22:22

I was trying to find out how to enable JavaScript Intellisense for webservices' client-side proxy classes when we are accessing client-proxy classes in external JS files?

I couldn't find a simpler solution than to:

  1. Run the application
  2. Download the client-side proxy class
  3. Save the content to a JavaScript file as the name of the Webservice and the extension of .js
  4. Add a /// <reference path="MyProxy.js" /> to the external JS file
  5. Intellisense enabled!

Is there an easier way of doing the same?




Mar 27 2008

AJAX Client Library Presentation @ Microsoft Office

Category:[email protected] @ 17:37

Yesterday I delivered a session on ASP.NET 2.0 AJAX Extensions 1.0 - Client Library.

This presentation was part of a two-days free training Wessam Zeidan ( and I delivered for a selected group of the Lebanese developers that are part of the LebDev.NET User Group members.


You can download the pptx file from here (

As for the sample codes, you can follow the source code that ships with the book: AJAX in Action ( I have used the same code to show some samples!!


Hope this helps,


Mar 27 2008

Client Application Services Part 3

Category: ASP.NET 3.5 | Windows Forms[email protected] @ 14:25

My third article in the series of articles on Client Application Services is now published on This is the last article in the aforementioned series! Hope you enjoy it! You can check it at: Client Application Services Part 3 (

Make sure to read the previous two parts before going on with this new part! Here are the links for Parts 1 and 2.


  1. Client Application Services Part 1 (
  2. Client Application Services Part 2 (


Hope this helps,

Tags: ,

Mar 27 2008

Nested MasterPage Not Firing Page_Load Event

I faced a situation today where I am trying to attach to the page_load event of a child nested master page to load some data on the master page itself. The event was not firing at all. Later on I figured out that the AutoEventWireup property on the Page directive is false!!!

Seems by default when you create a nested master page, its AutoEventWireup property is set to false! What you need to do is just make it true!


Hope this helps!


Tags: ,

Mar 27 2008

RowIndex inside ListView_ItemDataBound event

Category:[email protected] @ 10:10

If you need to access DataKeys of a ListView from inside the ItemDataBound you need to use the ListViewDataItem class. The ListViewDataItem class represents an individual data item in the ListView control. Every data item refers to a record in the data source.

The trick is to use the ListViewDataItem.DisplayIndex property! This property returns the index of the currently bound row inside the ListView collection of items.

A sample code could help more:

protected void PostList_ItemDataBound(object sender, ListViewItemEventArgs e)
    // Get the listview
    ListView listView = (ListView)sender;

    //Get the item object.
    ListViewDataItem dataItem = (ListViewDataItem)e.Item;

    // Only data items are allowed
    if (e.Item.ItemType != ListViewItemType.DataItem) return;

    // Get the PostID from the ListView's datakey
    int postID = int.Parse(listView.DataKeys[dataItem.DisplayIndex].Value.ToString());



The ListView DataKeyNames had a value of "PostID" which represents the primary key column in the data table.

First of all you cast the e.Item property to an instance of ListViewDataItem, then using the DisplayIndex property you can access the DataKeys of the currently bound row!


Hope this helps,


Mar 25 2008

Using The Silverlight DataGrid

Category:[email protected] @ 07:19

A very nice walkthrough on using the new Silverlight DataGrid can be reached here: Using The Silverlight DataGrid (

This tutorial is by Scott Morrison (


Hope you enjoy it!


Mar 25 2008

ASP.NET MVC Source Code Now Available

Category:[email protected] @ 07:16

Scott Guthrie announced few days ago that the ASP.NET MVC Source Code is now available on

In fact, MSFT opened up a new ASP.NET CodePlex project ( to share the source code of several ASP.NET related upcoming project releases.

Read on on Scott's post here (


Thank you Microsoft!



Mar 24 2008

Happy Easter

Category:[email protected] @ 07:00

I want to wish you a Happy Easter for all those who had their easter yesterday! May this easter bring you the hope, love, safety, and prosperity!

Happy Easter!