Apply Expand All and Collapse All to Collapsible Panels in ASP.NET AJAX and jQuery

by mosessaur| 22 December 2008| 15 Comments

I got many feedbacks in my previous posts "Building a grouping Grid with GridView and ASP.NET AJAX toolkit CollapsiblePanel" & "GridView Grouping Master/Detail Drill Down using AJAX and jQuery"  asking to for toggle all (Expand All or Collapse All) feature in CollapsiblePanelExtender as well as to in jQuery. Actually I didn't have much time to walkthrough this and provide a demo about it.

Today I got a chance to write few code snippet to run this feature. It was very simple for both jQuery also for ASP.NET AJAX.

More...

Book Review: Entity Framework Tutorial

by mosessaur| 20 December 2008| 0 Comments

Information About the book:

Book Title: Entity Framework Tutorial
Book's Page: http://www.packtpub.com/entity-framework-tutorial/book
Book Cover:

Chapters: 8
Type: Tutorial
Publisher: PACKT Publishing
Author: Joydip Kanjilal

Introduction:

Since the release of .Net 3.5 SP1 & VS.NET 2008 SP1 which include Entity Framework v1 I started to play with EF and discover its usage and differences between it and LINQ to SQL.

Last month I got a change to have a book that walks through Entity Framework by tutorial. This book was Entity Framework Tutorial. The books itself is very small. It has a clear focus and scope; to put you on the road on how to build & use Entity Model of Entity Framework following comprehensive tutorials.

About Entity Framework Tutorial Book:

The book is small one, 228 pages on 8 Chapters. This books is targeting beginners who never used or even heard of Entity Framework. But of course the reader should be experienced developer with Microsoft .Net (general), ADO.NET & C#.

More...

Going live with Egyptian Yonklies Network though Yonkly.com

by mosessaur| 05 December 2008| 4 Comments

I received an invitation to create first Egyptian Twitter like community on Yonkly.com. Thanks to Emad Ibrahim Creator and Founder of Yonkly.

Before I go further; you might ask What is Yonkly? My answer is: it is an enhanced twitter like mini blogging service. It is an open source project based on ASP.NET MVC. It is one of the first projects developed with early preview releases of ASP.NET MVC. This project was developed by Emad Ibrahim.

More information about Yonkly can be found at http://www.emadibrahim.com/category/yonkly/. You can download bits of this project from CodePlex.

2 different flavours of Yonkly are available through Yonkly.com, and Yonkly.net. The public Twitter clone is available at Yonkly.net, this is exactly like twitter with additional features like Groups. The other flavour which I am going to call community like edition is available under Yonkly.com. At Yonkly.com you can create your own community like Egyptian Yonklies I just created for Egyptian Tweeters. Both are in Beta as ASP.NET MVC itself is beta. Currently it require an invitation to be able to create your own network under Yonkly.com.

I think what is available on Yonkly.net should be available for each network under Yonkly.com. But this is something Emad should decide.

Today I was exploring Yonkly features while I was setting up egyonklies.yonkly.com. I was amazed by the provided features which I am sure is going to be enhanced and improved upon the release of ASP.NET MVC and in the upcoming releases of Yonkly.

More...

NDepend the massive code analysis tool for every developer

by mosessaur| 22 November 2008| 3 Comments

Before I start on this, I am sure I am not going to full fill all what I want to express about NDepend. NDepend takes your to the deep dark corners of your code and lights up those bright corners in it. Thanks to Patrick Smacchia and all this product development team for such great tool.

What is NDepend?

I don't think I can explain better than what is written in its web site:

"NDepend is a tool that simplifies managing a complex .NET code base. Architects and developers can analyze code structure, specify design rules, plan massive refactoring, do effective code reviews and master evolution by comparing different versions of the code.
The result is better communication, improved quality, easier maintenance and faster development."

So it is a massive code analysis tool, analyse every aspect of your code and produces informative reports with detailed matrices, diagrams and charts that should help you improve your code.

NDepend also generate and HTML report with all code analysis made alone with matrices and attached diagrams, figures and charts. One good thing I loved about this report, is when I found a term that I don't understand there is a link that takes me directly to online help where this term is defined. This helped me a lot, because some terms I am not familiar with, maybe my English or I am bad Engineer :o), either reason, it helped me and sure would improve any of those 2 defects in me :o).

Not only NDepend gives you these reports about your analysed code, but also it allows your edit constraints on and queries that produce these reports.

More...

Tips & Tricks when working with jQuery and ASP.NET AJAX

by mosessaur| 17 November 2008| 3 Comments

I posted about how to build and extender control using ASP.NET AJAX with jQuery. During my work I fall into few issues that I resolved and wished to share them with you.

These issues are related to callback functions in jQuery. For example when calling slideUp(speed, callback) or slideDown(speed, callback). Same thing when calling each(callback) function except that the callback in each(callback) function takes 2 arguments while those in Effects functions take no arguments by default -refer to jQuery documentation for more details-.

What are the issue exactly?

In all callback function in jQuery, "this" keyword will reference the DOM Element. For example in slideUp or slideDown functions if you specified a callback like this:

//Collapsed is your callback function
$('#elementId').slideDown(Collapsed);

Your callback function Collapsed should look like this:
function Collapsed() {
  //"this" refers to dom element
}

Now if you used "this" keyword in the callback function context it will reference the DOM Element which you are sliding down or up or making any kind of effects on it.

More...

PagedList Sorted Edition

by mosessaur| 04 November 2008| 10 Comments

Me and Amr Elsehemy are working together in something and he requested a feature in some APIs I built. In fact he liked the Rob Conery's PagedList that had been modified by Troy Goode. He used it on his jBlogMVC post series about building Blog Engine using MVC.

That was pretty simple and I noticed something missing on the PagedList that I wished to add! What about sorting. I mean build a PagedList that is sorted. So I made slight changes to the enhanced PagedList made by Troy to support sorting.

Prerequisites:

It is required that you refer to Rob Conery's PagedList and the modified version by Troy Goode before you proceed in order to understand how this PagedList is useful and helpful with MVC and LINQ to SQL as well as LINQ to Entities.

Summary of changes:

To summarize the changes I made, simply I used Lambda Expressions to enable sorting. And had to modify Class declaration (with constructors) and the Initialize method. Sorting is provided by OrderBy extension method. Please return to method documentation for more details.

More...

Building jQuery and ASP.Net AJAX Enabled Controls, The jQueryCollapsiblePanelExtender Part 2 Server Control

by mosessaur| 27 October 2008| 7 Comments

In the previous part I talked about how to build the client control. In this part I'll show how to put it all together to build an ASP.NET AJAX Enabled Server Control. You can view the demo that demonstrate control usage here.

The good thing about ASP.NET AJAX is that it supports fully programmable interface for both Server and Client control. And make a connection between both control. So you just need to put the control declaration on the ASPX page and ASP.NET will make it work for you. On the other hand, you have full access to the client APIs so that you can do some manual calls to the client APIs as well.

Building the Server Control:

This is an ASP.NET AJAX Extender control. Means it extends existing ASP.NET control to enable ASP.NET AJAX on it. In this case this extender extends ASP.NET Panel control, that is why it is called CollapsiblePanelExtender. Here is an article to show you in details How To build Extender Controls.

Basically jQueryCollapsiblePanelExtender I am building here inherits directly from ExtenderControl. This required to implement 2 methods GetScriptDescriptors and GetScriptReferences which I am going to explore later. But now, I want to take your attention that I am using jQuery, and I wanted the developer to have the option to specify the path of the jQuery library. If he/she did not specify the path, the default path is used, which is the the one hosted by google at http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js. To do that I made a property and Call jQueryScriptPath that gets and sets jQuery javascript library path.

More...

Building jQuery and ASP.Net AJAX Enabled Controls, The jQueryCollapsiblePanelExtender Part 1 Client Control

by mosessaur| 26 October 2008| 11 Comments

At the end of the last month (September 2008) Microsoft announced that it will be shipping jQuery with Visual Studio going forward. It was a great news for all ASP.NET developers who are jQuery fans as well as jQuery and ASP.NET AJAX folks like me. Before and after that, there were many posts made around the same subject. It will take a full post to list all these posts. But it would be easy for me to list ASP.NET jQuery heroes around such Rick Strahl, Dave Ward and Matt Berseth. There are many other heroes around such as Bill Beckelman who made a great collection of ASP.NET with jQuery Demos.

For specific posts around ASP.NET AJAX and jQuery I recommend to refer to the following posts by Dave Ward's blog:

Introduction:

We all heard about and maybe worked with ASP.NET AjaxControlToolkit! A set of wonderful controls, but they are heavy, maybe not all of them but many of of them. Beside they require lots of script files which increase the response size.

I was thinking of building jQuery UI Widgets to clone some of AjaxControlToolkit controls. And after Microsoft announcement about jQuery I had another idea! I always liked how ASP.NET AJAX component model, both client and server models. It is easy to build ASP.NET AJAX Enabled Controls especially for ASP.NET control developers. ASP.NET AJAX client and server architecture really ease the development ASP.NET AJAX Enabled Controls and also the core ASP.NET AJAX client library has no massive performance issues, and it is widely used.

On the other hand, I loved the ease of using jQuery as well, how fancy it provides UI Effects and manipulation of DOM. Many many things I wished to have in ASP.NET AJAX were exist in jQuery. So I though of building an ASP.NET AJAX Enabled Control to clone the existing AjaxControlToolkit's control CollapsiblePanelExtender. And use ASP.NET AJAX client and server component model while using jQuery for UI Effects. In this case it would be collapsing (Slide Up) and expanding (Slide Down). [View Demo]

More...

Inheritance and Associations with Entity Framework Part 3

by mosessaur| 01 October 2008| 1 Comments

On part 1 and part 2 I explored how to apply 2 different inheritance models (TPH & TPT) in Entity Framework. In this part I'm going to demonstrate associations between 2 base entities. And how to filter end properties to return specific type (sub entity). Download the sample.

Review Association Ends:

In previous part when I added department tables to the entity model diagram, an associations between Person and Department entities was automatically defined. This relation actually demonstrate the relation between Administrator and Department. It is one-to-many relationship where one person can be administrator of one or many departments.

A collection of Departments is created on Person table and therefor it is inherited on all sub entities! But this make no sense, as a student or instructor has nothing to do with this collection. Beside on the other end at Department a property of type Person is created -I renamed it to Administrator-, while this shouldn't be just any Person, this Person must be of type Administrator.

A few modification should take place in here. The existing association should be deleted and the association ends should be define between Administrator Entity and Department Entity. To do that follow the following steps:

More...

Inheritance and Associations with Entity Framework Part 2

by mosessaur| 29 September 2008| 5 Comments

In the previous part I discussed Table-per-Hierarchy Inheritance, in this part I'll go through Table-per-Type Inheritance model. There is a video demonstrating this model if you wish to watch. Here I'll update my previous sample with new entities that demonstrate the Table-per-Type Inheritance model. For the differences between 2 models and definitions return to 1st part. The updated sample can be downloaded from here.

How to define a model with Table-per-Type Inheritance:

At the beginning I'll explore the database design for this subject, and explain why Table-per-Type must be used to model the inheritance:

More...