Showing posts with label Tech Gossip. Show all posts
Showing posts with label Tech Gossip. Show all posts

Saturday, June 12, 2010

Microsoft is going the jQuery way

With jQuery gaining popularity day by day and Microsoft extending support towards it through its Visual Studio IDE, it looks like the future in ASP.NET is going to rely heavily on jQuery. Before I move forward with the integration part which is the actual topic of this blog, let me give you an idea on what jQuery is. If you don't know about jQuery yet or have not followed it recently, you must now. Use of jQuery is getting serious not only with .NET environment but any other environment. To me, it looks like jQuery is going to mean much more in the near future; this I can guess from the increasing number of code examples on the web using jQuery just the way you might have noticed the increasing usage of LINQ.

jQuery is a light weight JavaScript library that is about to change the way you write JavaScript. I have seen people getting addicted to jQuery once they come across it, and why not?...so are its virtues! The latest version of jQuery library is just 24 KB and using just this library in your application, you can do miracles. If you visit the jQuery site, the tag-line says "write less, do more".  And that's true. To use jQuery, all you have to do is visit the jQuery site I gave earlier and download the latest version of the library. If you want it only for use on your website, you can pick the production (minified) version, or if you want to explore it further, you may go for the development version. Once the .js file is downloaded, copy the file to your project folder and start using it by including the file in your source just the way you would include any .js file.

Here is a snapshot where I have used jQuery to display an alert on click of an anchor text. Thios i to give you an idea on how you can use jQuery in Visual Studio. I believe you can carry it forward from here.

How about writing some JavaScript that will fade or slide a <div> when user clicks on it? Just a style change of "display:none" is going to disappear the div...but we want to make it a smooth slide out. You are already thinking of a plethora of code with usage of opacity and setTimeouts, right? But then you also have to put some additional checks to make sure the code is compatible with different browsers!...I know I am scaring you, but now that you have the jQuery library with you, look at what you need to write to get all the above done:
$("div").click(function ()
{
      $(this).hide("slide", { direction: "down" }, 1000);
});
Not only this, what about implementing the complete AJAX based callback in just this much of code:
$(document).ready(function()
{
     $.ajax({
          type: "POST",
          url: "pagemethod.aspx/sayHello",
          contentType: "application/json; charset=utf-8",
          data: "{}",
          dataType: "json",
          success: AjaxSucceeded,
          error: AjaxFailed
    });
});

function AjaxSucceeded(result)
{
    alert(result.d);
}

function AjaxFailed(result) 
{
    alert(result.status + ' ' + result.statusText);
}
That's impressive, isn't it? I am not going to focus on jQuery tutorial here. There are plenty of tutorials available on the web you can access. Best place to start with is the jQuery site's tutorial itself. When I post more articles on jQuery adventure in .NET, I will put some code examples. You can already find some jQuery snippets for Visual Studio in Codeplex that you might want to experiment with once you have done with your basics on jQuery.

What is important to observe how Microsoft is incorporating jQuery into .NET developers' world by extending support to jQuery and even making code contributions to it. In 2008, Scott Gutherie already committed a lot for jQuery from Microsoft in his blog. He mentioned that Microsoft will be shipping jQuery with next version so Visual Studio. In fact, when you create a new web site in Visual Studio 2010, you will find the jQuery files in a scripts folder added by default. I still have to experiment more with it in the 2010 version; will let you know.


Besides, jQuery team has developed a version of jQuery library that is documented as per Microsoft XML comment standards because of which jQuery objects and their properties and methods are now also available in Visual Studio intellisense. You can visit the downloads page on jQuery site and download the Visual Studio version. When you include this documented .js file in your code, the intellisense will guide you through jQuery syntax as you can see below in one of my experiment's screenshot:

This should be possible with Visual Studio 2008 since this IDE has good support for JavaScript. However if you don't have the Service Pack 1 of the IDE, you may face some issues. In that case, get the Service Pack and then refer this knowledge base.

It is pretty sure now that the forthcoming ASP.NET AJAX will be built on jQuery or at least will be largely based on it, make it more important for .NET developers to make jQuery a part of their lives.

A little while ago, Microsoft added jQuery templates and data linking which you can read about here. I will get back to this in some other post with a bit of study. But continuing the effort towards jQuery. Microsoft came up with jQuery Globalization plugin just yesterday. The System.Globalization namespace and CultureInfo class in .NET framework gives you enough liberty to globalize or localize your code. You know how easy it is to convert some date or numeric value into a specific format. For example, I can easily convert my date to English or Dutch format in my server side code as:
using System;
using System.Globalization;
using System.Threading;
public class FormatDate
{
   public static void Main()
   {
      DateTime dt = DateTime.Now;        // Sets the CurrentCulture property to U.S. English.
      Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
      Console.WriteLine(dt.ToString("d")); // Creates a CultureInfo for German in Germany.
      CultureInfo ci = new CultureInfo("de-DE");
      Console.WriteLine(dt.ToString("d"));
   }
}
This is just a simple example. In fact, the power of globalization in .NET extends to every datatype and conversion, making it so handy to format our data. Unfortunately, it isn't that easy in JavaScript or the client side code to do the same. This Globalization jQuery plugin is here to solve the same problem, at least making it very very simple. By using language tags, it is not only possible to imitate the CultureInfo scenario but extend the same power into your JavaScript Code. You can read about the plugin here. I will post more as I discover more, but the moral of the story remains: jQuery is here to stay and get more and more involved. If you want to stay afloat, gulp it!

Thursday, November 1, 2007

Whats in a name!

Ever wondered why software companies go for code names of the products they are about to release? Microsoft is famous for its spicy code names. From Whistler for XP to Longhorn for Vista and Vienna for Windows 7, they have a wonderful set of code names they have come up with in all these years. But I wandered through the web just to get an insight about why code names do not last long. And if they are temporary, why not go for a standard name at once, and waste time hanging around with code names!

I have the answer now. The industry is not as simple as it sounds. While design and development of a product is being worked on, software companies keep their marketing department busy with planning sales and advertising. There are license issues, market studies and lot many legal issues to be dealt with meanwhile. So developers come up with a name for their baby; and that is why sometimes the code names have nothing to do with the product itself.

If you are curious to know what the code names Microsoft has used for its products yet, check this list on Wikipedia. And if you are wondering what does the title of this blog has to do with it...well I repeat William Shakespeare's words "what's in a name!".

Friday, October 26, 2007

Microsoft weds Facebook

In just about 3 years time, like many other IT companies reaching appreciable height of success in short span, Facebook has become a popular name in social networking environment. With the news of Facebook being evaluated at $15 billion and Microsoft benefiting from a $240 million stake, things are going to be more challenging for Google.

For IT people around the world, it has always been a fun to watch the catfight between Google and Microsoft. There have been comparatively fewer times Microsoft has gained advantage over Google than the vice versa, but with an elite advertising partnership with Facebook, Microsoft has made an another small victory.

Wednesday, October 24, 2007

Windows stripped naked

"So that's kind of proof that there is actually a pretty nice little core inside of Windows." This was a pretty cool statement. Have you had a chance to watch Eric Taut's presentation on the concepts of Windows 7 and virtualization strengthening into Windows? If you missed, watch it here.

Eric Traut is the right person to hear about Windows kernel from, not only because he leads the core team of about 200 engineers which is primarily responsible for Windows kernel and core technologies, but also because he knows enough that we would like to know. During the presentation, he does not hesitate to admit the importance of Linux for companies around the world and neither degrades the essence of Photoshop. But as he leads through the concept of virtualization and how Windows is going to embrace it, we realize that lately Microsoft has become aware of sharing its pride of being the best. Surely for the good.

Eric demos a tiny stripped core kernel of Windows NT loading in cute ASCII bootscreen which is just 25 MB in size and 40 MB of RAM, but is enough to run a simple http server. He calls it MinWin. Microsoft is stripping Windows to its tiny neat core and building it again from there, layer by layer, reusing code wherever usable. And they are not in a hurry. The next big release is scheduled for 2010 which is codenamed "Windows 7". Eric explains how Microsoft would like to provide a true VM concept based OS as he runs multiple versions of Windows (it was cool to see Windows 1 and 2 in action). The "hypervisor" is a small kernel (about 75,000 lines of code) that uses software partitions where guest operating systems go. If you find it difficult to watch the approx 1 hour video of Traut's presentation, check out this nine minute video of Minwin.

Letting go of the bulky Vista-size cluttered system and starting it afresh with better concepts from the core than its legendary polishing practice is bound to get Microsoft good competence, the same benefit that open source industry reaped by releasing the kernel to let poeple polish it at the core. Many would say Microsoft is borrowing ideas from open source. But I would say if Microsoft gave the world the concept of user-centric operating system, it has the right to evolve through time. Good news, it is starting now! The revival must not have been delayed further with ruling threats from Linux community.

Tuesday, September 11, 2007

Operating System Support

Windows XP has not been very friendly with me recently. Well, it is said that software goes parallel with hardware, and I use a PC with normal configuration without a UPS support in an unstable power environment. That makes me a bad operator and thus I would not like to blame the operating system.

There is a brighter side too. I am doing more debugging task with operating systems than I used to. Unfortunately more than half of the cases to solve the OS problems ended up in me reinstalling the operating system. Fortunately, it also encouraged me to look for better solutions. So guys, here is a couple of interesting resources you need. I will keep posting them here if I come across more of them.

Missing hal.dll? You do not need to reinstall. Check the solution here.

Need some information about what a dll is about and is that needed in your PC? Check the mega library. It is extensive, so don’t try to mess with the ocean. Sneak into and just check info about the dll you need to!