Sunday, February 12, 2012

Books must be Read


The following are books should be in the shelf of each .NET developer
  1. Object-Oriented Analysis and Design with Applications  by Grady Booch

  2. Code Complete by  Steve McConnell
  3. .NET via C# by  Jeffrey Richter




Wednesday, September 28, 2011

Tracking page events in ASP.NET Page

NOTE: I added this article in Code Project .

This is a simple way to track the page events in ASP.NET, I used it to follow the sequence of raising events, also it can be used as a debugging methodology.

1- first when you create a new asp.net page add this code:

Dim SeqNo As Integer = 0

Private Sub Page_AbortTransaction(sender As Object, e As System.EventArgs) Handles Me.AbortTransaction
SeqNo += 1
Debug.Print(SeqNo.ToString & " - AbortTransaction")
End Sub

Private Sub Page_CommitTransaction(sender As Object, e As System.EventArgs) Handles Me.CommitTransaction
SeqNo += 1
Debug.Print(SeqNo.ToString & " - CommitTransaction")
End Sub

Private Sub Page_DataBinding(sender As Object, e As System.EventArgs) Handles Me.DataBinding
SeqNo += 1
Debug.Print(SeqNo.ToString & " - DataBinding")
End Sub

Private Sub Page_Disposed(sender As Object, e As System.EventArgs) Handles Me.Disposed
SeqNo += 1
Debug.Print(SeqNo.ToString & " - Disposed")
End Sub

Private Sub Page_Error(sender As Object, e As System.EventArgs) Handles Me.Error
SeqNo += 1
Debug.Print(SeqNo.ToString & " - Error")
End Sub

Private Sub Page_Init(sender As Object, e As System.EventArgs) Handles Me.Init
SeqNo += 1
Debug.Print(SeqNo.ToString & " - Init")
End Sub

Private Sub Page_InitComplete(sender As Object, e As System.EventArgs) Handles Me.InitComplete
SeqNo += 1
Debug.Print(SeqNo.ToString & " - InitComplete")
End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
SeqNo += 1
Debug.Print(SeqNo.ToString & " - Load")
End Sub

Private Sub Page_LoadComplete(sender As Object, e As System.EventArgs) Handles Me.LoadComplete
SeqNo += 1
Debug.Print(SeqNo.ToString & " - LoadComplete")
End Sub

Private Sub Page_PreInit(sender As Object, e As System.EventArgs) Handles Me.PreInit
SeqNo += 1
Debug.Print(SeqNo.ToString & " - PreInit")
End Sub

Private Sub Page_PreLoad(sender As Object, e As System.EventArgs) Handles Me.PreLoad
SeqNo += 1
Debug.Print(SeqNo.ToString & " - PreLoad")
End Sub

Private Sub Page_PreRender(sender As Object, e As System.EventArgs) Handles Me.PreRender
SeqNo += 1
Debug.Print(SeqNo.ToString & " - PreRender")
End Sub

Private Sub Page_PreRenderComplete(sender As Object, e As System.EventArgs) Handles Me.PreRenderComplete
SeqNo += 1
Debug.Print(SeqNo.ToString & " - PreRenderComplete")
End Sub

Private Sub Page_SaveStateComplete(sender As Object, e As System.EventArgs) Handles Me.SaveStateComplete
SeqNo += 1
Debug.Print(SeqNo.ToString & " - SaveStateComplete")
End Sub

Private Sub Page_Unload(sender As Object, e As System.EventArgs) Handles Me.Unload
SeqNo += 1
Debug.Print(SeqNo.ToString & " - Unload")
End Sub


2- Run the Web application in Debug mode (by selecting Debug-> Start Debugging OR press F5).

3- After the page is viewed completely on the browser, check the output window in Visual Studio (if it was not opened select View -> Output OR press Ctrl+Alt+O)

4- you will see something like this:

(removed text )....

1 - PreInit
2 - Init
3 - InitComplete
4 - PreLoad
5 - Load
6 - LoadComplete
7 - PreRender
8 - PreRenderComplete
9 - SaveStateComplete
10 - Unload

( removed text )....

Saturday, September 17, 2011

Razor .... back to the Classic age


    A lot of developers who checked the Razor View Engine for the first time - including my self- had the following question up to their mined ... "hay! this is like classic ASP .... are we going back to spaghetti-code again?!!!".
    Will, comparing ASP.NET 1.0/2.0 with Classic ASP, I admire that there was some advantages for the later; with classic ASP you have a light wight tool with more control over the heavy set of .NET controls included in each ASP.NET page. also ....
"Classic ASP programming is the beautifull language in simplicity why? it is traditional and only has basic functionality, whenever you need a custom function/method you need to build it yourself. This make it different, this is usefull to exercise your programming logic. For example if you need to clear the HTML tags in PHP you simply apply the striptags method but in classic asp you need to build your own code with your own programming logic."
However, When Microsoft developed ASP.NET MVC ... one of it important parts was the View Engine Concept which is used inside the UI files. The ASP.NET team designed Razor as a new easy to learn,  simple syntax, and coded-template view-engine, beside its .NET based, Razor is much more easy than classic ASP, one good sample is the concept of reusable code (i.e. _Layout pages) that Razor provides

At last, its important to know that the Razor is not for ASP.NET MVC projects only ... you can build a ASP.NET website using Razor syntax project template





 

Sunday, August 14, 2011

Visual Studio LightSwitch ... for light Business

I had installed the new Microsoft product Visual Studio LightSwitch today.
it was just after clicking the lunch button at the end of the installation that I realized that it's an addition to the Visual Studio 2010 which mean that you need to have it installed on your machine (you need SP1 also).
Visual Studio LightSwitch help developers and low level skilled IT professionals to develop a small or department level applications in a smooth, high speed, wizard-like process. It took me less than 5 minutes to create my first application (full functional that have one table with a single screen maintaining data).
you can get LightSwitch from its home page and find a lots of resources to learn about .... enjoy.

Tuesday, August 9, 2011

20 years of web


It was on Augast 6th 1991 when the first web site was published with the url http://info.cern.ch/ (still active).

no comments ... just view the site and you will know the story

Sunday, May 2, 2010

The old first statement .... "Hello World!"

When I start learning programming at school, i had that first sample program to write, "Hello World!" .

I believe this statement means something. It's like that the software program starts to communicate with the world, its like a new baby crying to announce his arrival to the world.

Software is becoming an essintial part of our modern life, their is no place you cannot find software; in house, workplace, even in your pocket (if you keep your mobile phone in).