Which language is the best to learn, PHP or ASP.NET?

There’s been a lot of discussion about this topic and I guess everyone have different opinions about it. I am a fulltime freelance developer and do projects with PHP and ASP.NET so I may have a more neutral opinion about the two.

In the old days if you asked me to compare PHP and ASP, I would have said PHP without any hesitation. ASP was cumbersome to me with way too much overhead and lacked the OOP aspect. But these days with the newer .NET frameworks it’s much harder to make up my mind.

Both languages have their own pro’s and con’s. I come from a C++ background and writing code with C# and PHP both give me a lot of satisfaction, so on the style and object oriented coding level they are both on equal ground for me. I know ASP.NET has much better OOP support, but for what I need and the projects I do, PHP is fine. Without comparing too much low level differences between the two engines.

The things that stand out most about PHP are:

·         Platform Independence – And yes, I know there’s the mono framework that supposedly makes ASP.NET independent. Well in my opinion, if it was not natively build to be platform independent then it’s not. I don’t like hacks to make things work.

·         Easy Deployment – I’ve never once, deployed and ASP.NET application from a dev environment to a live environment without any issues. With PHP it’s almost always flawless.

·         An Abundance of Resources – You always find answers to questions, problems and third party classes to do things much easier than with .NET resources. Due to the open source nature of PHP development.

The things on the other end that I like more about ASP.NET development:

·         Access to the .NET Framework (CLR) – The libraries has everything you need built-in. There’s no need to download a class to do nicely formatted emailing or encryption, it’s all there.

·         Better UI controls out of the box – The grid components make it quick and easy to slap together a data viewing or editing screens. I suppose with add-ons to PHP like jQuery the same can be achieved.

·         Good Debugging Support – I am using Nusphere’s PhpED for development and it comes close with its debugging functionality, but nothing beats Visual Studio’s debugging support.

So which one do I choose?

Well, if I were new to web development and had to choose. I’d choose PHP. But I would also invest the time to learn ASP.NET in C# of course, not VB.NET.

I’ll continue to support both languages in my business. There are times when PHP is more suitable and others when ASP.NET makes more sense. A lot of my Government work also requires ASP.NET because of their licensing agreements with Microsoft. So it makes sense to learn both.

If you’re interested in quickly running through a comprehensive crash course in PHP with step-by-step examples visit http://www.php-skills.com

To learn ASP.NET go to http://www.ASP.NET for learning material.

Good luck!

Debugging in Visual Studio 2005 Stop to Work

One of my older ASP.NET projects required an update today and I struggled for hours trying to get VS to enter in debug mode. Everything was working fine before in the project and Debug is enabled on the project, but when VS starts it opens the site and then immediately exits the debug mode preventing any breakpoints to be reached.

After a long search I found that the problem was related to IE8 that I installed recently. I am not sure what the cause is but the fix worked so here we go:

1.       Install another browser, FireFox, Google Chrome or something. Start that browser and set it to be default browser.

2.       Close all IE browser windows.

3.       Now start IE, and set IE as the default browser.

4.       Magically, VS debugging now works again.

Don’t ask me why. I don’t really care what caused it as long as the debugging is back. Hope it helps you.

Outlook 2007 Blocks HTML Forms in Emails

One of the security features of Outlook 2007 is to block html forms inside emails. Outlook parses the html form into its own custom (non-editable) format but doesn’t always succeed to correctly display the values from the input fields. To save yourself from headaches and customer complaints, modify your code to attach any HTML file that contains a form to the email as opposed to embed the html in the body of the mail.

“…has too many arguments specified” error on ASP.NET GridView

The worst web development project is a project you inherit from someone else. There are some things I don’t do in any of my ASP.NET projects one of them being automatic editing provided by the GridView, I prefer to be more in control and usually build a popup or something.

Recently I took over a project from a developer that loved in-row editing and when I had to add new screens I decided to use the same format to keep consistency.

Not knowing (out of preference) about all the pitfalls I got a bug when you initiate the update. The GridView is linked to a SqlDataSource with an UpdateCommand pointing to a stored procedure. When the user click on the Update button I added in a template field I get an error saying: “Procedure or function myProcedureName has too many arguments specified.”

After a few hours of poking around on the web I finally got an answer. My template fields contained fields that are not updated in the stored procedure. For the fields that were not supposed to be updated, I also used the Bind function as opposed to Eval. I changed the Binding in the EditItemTemplate from Bind(”SomeDatafield”) to Eval(”SomeDataField”) and it solved the problem.