Chris Pietschmann

husband, father, hacker, entrepreneur, futurist, innovator, autodidact


Silverlight: Anatomy of an .XAP file

Silverlight 2 Beta 1 just came out this morning, so I started checking it out immediately. I installed the Silverlight Tools for Visual Studio and noticed that when a Silverlight Application is compiled a .xap file is created that contains the application. But, what exactly is a .xap file, and what exaclty is in there? What is an .xap file? A .xap file is basically a compiled Silverlight application. The file is actually a .zip file that contains all the files necessary for the application. ... [More]

MIX'08 - KeyNote Notes of Ray Ozzies talk

I watched the MIX'08 Keynote online this morning, and here are some notes I took.  Notes from Ray Ozzies talk: Some investments will be realized this week: Internet Explorer 8 Silverlight 2 Advertising on the web is expected to grow from $40 billion to $80 billion over the next few years. Social networking is growing and will become an integral part of the web just as familiar as Files and Folders are on the desktop. Web will be used as a hub in using and managing al... [More]

Add System Menu Items to a Form using Windows API

This is something I used to have a code snippet for in VB6, but I haven't needed to do this in a while so I never wrote up an example in .NET. So, here's the simple code necessary to add some custom menu items to your applications System Menu. If you're not familiar, the System Menu is the menu that shows up if you click on the apps icon in the upper left or if you right click the app in the taskbar. [More]

Simple JavaScript Object Reflection API (.NET Style)

I was thinking about how JavaScript JSON serializers go about serializing objects. But how does the serializer know about each of the objects properties? I figured JavaScript must have some method of object reflection (similar to .NET Reflection) and it does. Here's a simple Reflection namespace that allows you to more easily reflect through an objects methods and properties: [code:js] if (typeof PietschSoft == "undefined") var PietschSoft = {}; if (typeof Pietsc... [More]

JavaScript ForEach Equivalent

One thing with the For Loop in JavaScript is it doesn't seem to be very well documented that you can use it to do an equivalent of a ForEach loop. Here's a short example of doing the ForEach loop equivalent in JavaScript: var names = ["Chris", "Kate", "Steve"]; for(var i in names) { alert(names[i]); } In the above code, the variable "i" is our iterator and by using the "in" keyword the "for" loop actually loops through all elements in the Array for us. Using this you no longer have to worry ... [More]

.NET 3.5: JSON Serialization using the DataContractJsonSerializer

In ASP.NET AJAX Extensions v1.0 for ASP.NET 2.0 there is the JavaScriptSerializer class that provides JSON serialization and deserialization functionality. However, in .NET 3.5 the JavaScriptSerializer has been marked obsolete. The new object to use for JSON serialization in .NET 3.5 is the DataContractJsonSerliaizer object. I'm still new to the DataContractJsonSerializer, but here's a summary of what I've learned so far... Object to Serialize Here's a simple Person object with First Name and La... [More]

.NET: Why aren't Private Abstract methods allowed?

Sometimes when creating base objects you want to create methods that are overridable by object that inherit the base object, but keep the methods from being public. However, the compiler throws an exceptions when you try to define a method as "Private Abstract". Why doesn't the compiler like "Private Abstract" methods? The reason for this is Private methods can not be overriden. So, essentially the Abstract is useless if the method is Private. How can I create a "Private" method that's a... [More]

JavaScript Function Tips and Tricks

First, What is a JavaScript Function? As defined by a JavaScript Function is: "A function is a reusable code-block that will be executed by an event, or when the function is called." - You're probably thinking, "Well, Yeah. I knew that." But, how much do you really know about JavaScript Functions? JavaScript Function uses you already know Here's the most basic ways of using functions to get things done that most web developers are fa... [More]

The Purina Diet {Joke}

I don't know who originally wrote this, but I received it in an email the other day. I thought it funny enough to share. When someone asks you a dumb question wouldn't you like to respond like this?..... Yesterday I was buying a large bag of Purina dog chow for Athena the wonder dog at Wal-Mart and was about to check out. A woman behind me asked if I had a dog. What did she think I had, an elephant? So since I'm retired, with little to do, on impulse, I told her that no, ... [More]

Search Keyword Highlighter BlogEngine.NET v1.3 Extension

In my previous blog, I used the se_hilite.js file from Scott Yang to hightlight the search keywords people used to search for my site when they are referred to my site via the search engines. This is functionality that I want to maintain, and I couldn't find an existing extension. So, I decided to write one. This is a really simple extension, and a neat feature to have. Here it is... [More]

I just finished migrating to BlogEngine.NET...

I just finished migrating my blog over to use BlogEngine.NET. The process was very painless. I only had to do two things: 1) write a sql script to import my posts/comments/tags from my old blog into BlogEngine, and 2) setup some redirect pages to redirect traffic to the new urls. Now, I just need to find or create a better theme to use.

Bing Maps: Draw a Circle Radius Around a Lat/Long Point

I get requests on how to draw radius' around points on the map. And, up until now, I never needed to do it myself, so I didn't have a code snippet to do it. I did a search and quickly found an example over at viavirtualearth on how to do it in an older version of Virtual Earth. Other than being coded for an older version of Virtual Earth (and incompatible with VE6); it's coded to only handle drawing a radius in Kilometers. So, I decided to upgrade the code example to support VE6, and support bo... [More]

Virtual Earth Plus ASP.NET AJAX Breaks In Safari!

Update 5/17/2008: This issue has since been fixed with the release of the Virtual Earth v6.1 release. There is still a small issue related to the CalendarExtender and Virtual Earth that only occurs in Safari. You can read more about it here.   I do alot of development with ASP.NET AJAX and Virtual Earth, and each of them work fine by themselves in Safari 3 on Windows. However, if you use them both on the same page, it will cause ASP.NET AJAX to break and stop working in Safari. This... [More]

Virtual Earth v2 Being Depricated March 31st

I'm not sure how many apps out there are still on Virtual Earth v2, but Microsoft has announced that Virtual Earth v2 will be depricated on March 31st. So, if your app is still on VE v2, you better get working to upgrade it to VE v6 before v2 is turned off. Also, it's worth noting that there are a few breaking differences between v2 and v6, so it may take a little while to upgrade your app.

Virtual Earth: Calculate Distance of User-Drawn Polyline

A couple days ago I posted some code to "Calculate Distance Between Geocodes in C# and JavaScript", so today I decided to post a small sample program that shows a more "real world" example of puting that code to use. Here's a small program I wrote (in pure HTML and JavaScript) that allows the user to draw a polyline, and it automatically calculates the total distance between the points being plotted. Download the Distance Calculator Program Here A Web.M... [More]

Calculate Distance Between Geocodes in C# and JavaScript

There are times when I need code to calculate the distance between two geocodes (Lat/Long points). I don't need it very often and until now I didn't have a code snippet that I could jus copy and paste. I was searching and found Rob Conery's LINQ and Geocoding post. It's an interesting post and he includes a sample of how to use Lambda expressions in C# 3.0 to calculate the distance between two geocodes in Miles. I decided to copy his code snippet and make sure it works in .NET 2.0 and also conv... [More]

LINQ to JavaScript Interactive SDK Now Available!

I just put out another (yes, another) update to JSLINQ. This v1.02 release doesn't include any new LINQ functionality over the previous release, but it doesn't contain less bugs thanks to the New JSLINQ Interactive SDK and Unit Tests. View the JSLINQ Interactive SDK Download JSLINQ plus code for Interactive SDK I have also verified that the project is compatible with IE7, FireFox2, and Safari 3 for Windows.

LINQ to JavaScript: Update Release v1.01 With More Functionality

Today, I put out v1.01 update release to the LINQ to JavaScript (JSLINQ) Project. This update adds even more LINQ functionality; to view a list of what't been added go here. I'm currently working on adding some cool things to JSLINQ that will make their way into the next couple releases. Among these are a small JSLINQ Interactive SDK that will make its way into the next release, and some performance enhancements that Brennan Stehling suggested. If you have any suggestions for th... [More]

LINQ to JavaScript (JSLINQ) Open Source Project Launched!

I know LINQ is still rather fresh to everyone yet, and you may not have really used it much, but I just started a new Open Source project called "LINQ to JavaScript". Or, JSLINQ for short. This project brings the ease of querying data collections down to the JavaScript world. Here are some simple examples of using LINQ to JavaScript: var myList = [{FirstName:"Chris",LastName:"Pearson"},{FirstName:"Kate",LastName:"Johnson"},{FirstName:"Josh",LastName:"Sutherland"},{FirstName:"John",LastName:... [More]

Virtual Earth: Dynamically Load InfoBox Using ASP.NET AJAX

Loading alot of pushpins on the map can slow down your page in two ways: 1) Page load times can be slowed down, and 2) loading pushpins via ajax can be slow. To improve the performance (as in download and database query times) of loading pushpins on the map, you can load the Pushpin Shapes Title and Description on the fly. This allows you to only load the Pushpins Title and Description as it's needed, thus reducing the amount of data you need to send down to the client when initially loadin... [More]

Getting Started with Virtual Earth and ASP.NET AJAX

About a month ago, I wrote an article titled "Virtual Earth: Getting Started - Adding a basic Map to a page". In that article I explained the basics of using Virtual Earth with plain HTML and JavaScript. This time I'm going to explain the basics of using Virtual Earth with ASP.NET AJAX. Virtual Earth and ASP.NET AJAX Step 1: Create a new ASP.NET AJAX Web Site in Visual Studio 2005, or just an ASP.NET Web Site in Visual Studio 2008. Step 2: Open up the Default.aspx page... [More]

Introduction to LINQ

What is LINQ? LINQ (Language INtegrated Query) is more than just a new method of embedding SQL queries within code. It allows to to perform Strongly Typed queries on any kind of data, just as long as the collection of data implements the IEnumerable interface. The most important part is "Language Integrated". This allows you to more easily write queries in C# 3.0 and VB 9.0 such as:   IEnumerable<Person> filterExample1 = from Person in people     &nbs... [More]

2008 Microsoft Launch Event and Free Software

On February 27th in Los Angeles, CA, Microsoft is kicking off a series of "HEROES happen {here}" launch events nationwide. These are the official launch events for Windows Server 2008, Visual Studio 2008, and SQL Server 2008. And, one of the best parts is everyone that takes part in one of the events will be taking home a promotional kit with versions of all three products. Since the Milwaukee event isn't until May 8th, I've registered for the Chicago event on March 11th. I don't want to w... [More]

QBasic was my First Programming Language

Recently, I got to thinking about my beginning of programming, and the Basic language. So, I thought I'd explain my early history with Basic a little bit. Basic was Easy My first programming language was QBasic. The reason I started learning QBasic was for the following reasons: QBasic came for Free on the Windows 95 CD-ROM There were more help sites on the internet dedicated to QB than any other language at the time. There weren't many resources on C++ back in the day (about 1996), eve... [More]

JavaScript int.TryParse Equivalent

One of the most handy methods in .NET is the int.TryParse method. It makes it really convenient when evaluating a string value as an integer. But, JavaScript has no equivalent so you need to do your own evaluation every time. Here's a simple JavaScript method I wrote that takes the work out of evaluating a string to an integer: function TryParseInt(str,defaultValue) { var retValue = defaultValue; if(str !== null) { if(str.length > 0) { if (!isNaN(str)) { ... [More]