Microsoft Most Valuable Professional

Chris Pietschmann

An MVP From Wisconsin

Self Employed and time for contract work

I have decided to go out on my own and work full time getting my own business off the ground. It's going to be an exciting ride and I know I have what it takes to make it work. I'll be working on a few project ideas that I have (If you want to find out more info about what I'm working on, you'll just have to watch this blog for more info as it's posted.)

As a result, I will also have time to do consulting on a contract basis. I have 6+ years of software development experience using MS .NET Framework 1.x/2.0 doing both Windows Forms and ASP.NET development along with SQL Server 2000/2005, JavaScript/AJAX and more. I am willing to work on site only if your office is within a reasonable distance from my home (Milwaukee area), otherwise I am more than willing to work remotely.

If you are interested in hiring my services to work on a contract basis, please email me via the contact form on my website.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: General
Posted by crpietschmann on Wednesday, August 22, 2007 9:54 PM
Permalink | Comments (3) | Post RSSRSS comment feed


ASP.NET AJAX: Extensions to standard JavaScript base types

Working with JavaScript can be a challenge at times, and there are a number of helpful things that the ASP.NET AJAX Extensions are bringing to the table. One of the things it does is extend some of the standard JavaScript base types with additional functionality. This is actually rather neat, and is something that you may not find unless you dig through the ASP.NET AJAX documentation like I did.


Array

There are a number of extensions made to the Array base type, including "add", "remove" and "clear" functions that allow you to interact with your JavaScript Arrays much more like they are actually collections. This is my favorite Extension that they've added since Arrays are used so frequently with JavaScript.

Example Usage:
var myArray = new Array();

// Add some elements to the Array
Array.add(myArray, "String One");
Array.add(myArray, "2");

// Remove an element from the Arrray
Array.remove(myArray, "2");

// Clear all elements from the Array
Array.clear(myArray);

Another neat extension to the Array base type, is the "forEach" function. This function allows you to loop through the Array and execute some code on each of its elements. What makes this extension really nice it the fact that you don't need to use an iterator to loop through; it does that tedious stuff for you.

Example Usage:
var m = ['1','20','40'];

function appendPercentSign(element, index, array)
{
    array[index] += '%';
}

Array.forEach(m, appendPercentSign, this);


Boolean

A simple but effective one that's nice is the "parse" function that is added to Boolean. This one converts the string representation of "true" or "false" to their boolean counterparts.

Example Usage:

var one = new Boolean.parse("true");

 

Are there any problems?

I don't really see any problems with the extensions that have been added. However I do have a small convenience issue with the way you use the Array extensions. These extensions are static methods that are called and you need to pass the Array instance to them. Why not a more object oriented approach?

Current ASP.NET AJAX use of Static methods:
var myArray = new Array();

Array.add(myArray, "one");
Array.remove(myArray, "two");

function appendPercentSign(element, index, array)
{
    array[index] += '%';
}
Array.forEach(m, appendPercentSign, this);

Array.clear(myArray)


Propose more object oriented way:
var myArray = new Array();

myArray.add("one");
myArray.remove("two");

function appendPercentSign(element, index, array)
{
    array[index] += '%';
}
myArray.forEach(appendPercentSign, this);

myArray.clear();


Now don't you agree that the more object oriented approach is just easier to read? I'm not sure why they implemented these extensions the way they did, but they've got their reasons (they always do).

 

Can I add my own extensions?

Yes, you can, but remember the ASP.NET AJAX Extensions are necessary to add your own JavaScript Extension Methods. All it takes is a little JavaScript code that utilizes the Prototype functionality of JavaScript.

Example to make the Array extensions more object oriented:


Array.prototype.add = function(item)
{
 Array.add(this, item);
};
Array.prototype.remove = function(item)
{
 Array.remove(this, item);
};
Array.prototype.clear = function()
{
 Array.clear(this);
};
Array.prototype.forEach(method, context)
{
 Array.forEach(this, method, context);
};

In fact JavaScript is so flexible, you can use prototyping to extend any JavaScript object type whether it's a base type or one you or a framework you are using created.

Conclusion

The ASP.NET AJAX JavaScript Base Type Extensions have some nice enhancements to the existing JavaScript base types. Even though I think they could be implemented in a slightly more object oriented way, I do find the functionality they add to be very useful. It's really nice when there is functionality you can just use and it works.

 

Useful, Related Links:
ASP.NET AJAX: JavaScript Base Type Extensions
http://asp.net/AJAX/Documentation/Live/ClientReference/Global/JavascriptTypeExtensions/default.aspx

JScript Language Reference
http://msdn2.microsoft.com/en-us/library/29f83a2c-48c5-49e2-9ae0-7371d2cda2ff

ASP.NET AJAX and JavaScript Tutorials
http://asp.net/AJAX/Documentation/Live/tutorials/ASPNETAJAXAndJavaScriptTutorials.aspx

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: asp.net | General
Posted by crpietschmann on Sunday, August 05, 2007 12:30 AM
Permalink | Comments (0) | Post RSSRSS comment feed


LunchTimeCoder.ServiceMonitor v1.1 Released

I just posted up the latest release (v1.1) of my windows service monitor app.

Download LunchTimeCoder.ServiceMonitor v1.1

This is a small utility that monitors windows services running on the local machine or any maching on the local network. And notifies you via an icon in the system tray and a balloon popup telling you which services aren't running. You can also Start and Stop services from this utility.

New Features in this version:

  • Added ability to monitor services on any computer on the local network
  • The utility now remembers what services to monitor the next time it starts up
  • The services current state is now displayed next to its name

If you have any other suggestions for this little app, let me know. I've pretty much run out of any other feature ideas for this at the moment.

Hmm... What little app or component should I work on next?

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by crpietschmann on Friday, August 03, 2007 1:16 AM
Permalink | Comments (1) | Post RSSRSS comment feed


About the author

I'm Chris Pietschmann, go to the About Me page to learn more about me.

Search

Sponsors

Web.Maps.VE - ASP.NET AJAX Virtual Earth Mapping Server Control

Recent comments

Disclaimer


This work is licensed under a Creative Commons Attribution 3.0 United States License, unless explicitly stated otherwise within the posted content.
© Copyright 2004 - 2008 Chris Pietschmann