Chris Pietschmann

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

NAVIGATION - SEARCH

ASP.NET 3.5: Create AJAX Extender Controls using the ExtenderControl base class

As a followup to the "Create AJAX Server Controls using the ScriptControl base class" post I wrote a couple weeks ago, I've decided to write on how to create ASP.NET AJAX Extender Controls using the ExtenderControl base class in ASP.NET 3.5. There is already an article titled "Adding ASP.NET AJAX Client Behaviors to Web Server Controls" in MSDN, but it doesn't show all the code involved in creating Extender Controls, especially the JavaScript code. What is an... [More]

Silverlight: Load JavaScript from Embedded Resource and Execute Within Page

I've been playing around with Silverlight 2 Beta 1 alot lately, and one of the areas I've been focusing on is interoperability with JavaScript and the DOM. Here's a technique I've found that allows you to inject JavaScript into the page from within your Silverlight application. This example also starts with the idea that the JavaScript you are going to inject is stored as an Embedded Resource within your Silverlight Application. Step 1: Create your JavaScript (.js) file and... [More]

ASP.NET: Create AJAX Server Controls using the ScriptControl base class

I've been doing a lot with ASP.NET AJAX for almost 2 years now, including my Web.Maps.VE product. So, I've decided to spread some of my knowledge in this area by writing up some articles on things that I've learned and figured out. As a note, since .NET 3.5 is the "latest and greatest" version of the framework out at the time of this writing, this article targets .NET 3.5. This article also assumes you have a basic understanding of ASP.NET AJAX and JavaScript. What is ScriptControl... [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]

JavaScript Function Tips and Tricks

First, What is a JavaScript Function? As defined by W3Schools.com a JavaScript Function is: "A function is a reusable code-block that will be executed by an event, or when the function is called." - http://www.w3schools.com/js/js_functions.asp 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]

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: 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]

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]

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]

Web.Maps.VE - Virtual Earth Without JavaScript, plus .NET 3.5 Support just added!

Yesterday, I released the fourth update release (v1.00.04) of my Web.Maps.VE component. The main feature addition in this update is the addition of .NET 3.5 support. Below is an overview of the main features of Web.Maps.VE. For more information you can go here: http://simplovation.com/Page/WebMapsVE.aspx Implement Virtual Earth completely from server-side .NET code; No JavaScript Necessary In case you're not familiar, Web.Maps.VE is an ASP.NET AJAX Virtual Earth Mapping Server C... [More]

Virtual Earth 6: Align Mini Map in the Top Right corner of the Map

If you take a look at maps.live.com you'll see the Mini Map is in the Top Right corner of the map. Virtual Earth doesn't have any alignment options built in when showing the Mini Map. It just allows you to position the mini map using x and y offset coordinates relating to the top left corner of the map. This makes it really easy to show the mini map in relation to the top left corner, but what makes this tricky is the dashboard is already there. Here's small example I wrote ... [More]

Virtual Earth: Convert Road Map Style to Shaded Like maps.live.com does

What is the Shaded map Style? If you've used maps.live.com and Virtual Earth, then you've probably noticed that the Road map style in the Virtual Earth API isn't the same as it is on maps.live.com. This is because the Road map style on maps.live.com is actually not using the VEMapStyle.Road map style, but instead is using VEMapStyle.Shaded. The VEMapStyle.Shaded map style is the standard Road style with Shaded Contours drawn on the map, and is new to Virtual Earth v6.0. In th... [More]

Safari 3 for Windows: Enable JavaScript Debugging

As you probably know, Safari 3 doesn't allow you to turn on the debug menu within any settings dialogs. It also doesn't come with a JavaScript Debugger either. This makes it almost impossible to do any JavaScript development for Safari. Luckily you can turn on the debug menu, and there is a debugger you can download. Turn on the Debug menu Step 1: Open up the Preferences.plist file in notepad. In Windows XP:C:\Documents and Settings\USERNAME\Application Data\Apple Computer\Safari\Preferences.... [More]

Virtual Earth: Getting Started - Adding a basic Map to a page

What is Microsoft Virtual Earth? Virtual Earth allows any developer to implement mapping technology within their web sites and/or applications. The mapping techology behind Virtual Earth is the exact same technology that powers Microsoft's Live Maps website. Getting Started with Virtual Earth Lets add a Map to a page Step 1: Add a DOCTYPE declaration and specify UTF-8 as the pages character set at the top of the page <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Trans... [More]

12/2007: Code that I've Blogged over the last 6 months

Here's a list of links to all the different code that I've blogged over the last 6 months. .NET Framework .NET: How to Alias Namespaces and Data Types LunchTimeCoder: Windows Service Monitor that runs in the System Tray .NET 3.5: How to Convert from one TimeZone to another ASP.NET Google Charts API: an ASP.NET 2.0 Server Control Subsite Rewriting HttpModule for ASP.NET ASP.NET: RewritePath breaks HyperLink's ImageUrl in App_Theme file when path with slash is rewritten ASP.NET AJAX:... [More]

Cryptographic Extensions for Microsoft AJAX Extensions Framework

The Extensions for Microsoft AJAX Framework project over at CodePlex provides cryptographic services including secure encoding and decoding of data, as well as hashing and random number generation, and new methods for JavaScript native objects. This project is pretty cool, and could really grow into a huge library offering us what Microsoft isn't putting into the AJAX Extensions themselves. And, now we have an object oriented, JavaScript way of doing MD5, SHA1, HMAC and AES! Go check it out: ht... [More]

JavaScript: Add Search Engine Keyword Highlight Support to your site with ease

When looking at the source code for the BlogEngine.NET project, I noticed that they are implementing some javascript to highlight search engine keywords. What happens is when a user searches (using Google, Yahoo, MSN, etc.) and then clicks through to your site, this javascript then highlights any words on the page that match the keywords they are search for. This isn't critical functionality to add to a site, but it sure helps in making your site much more user friendly by allowing them to more ... [More]

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 ... [More]

LunchTimeCoder.AutoSlideShow v1.05 - some small enhancements

Today I spent a small amount of time enhancing the LunchTimeCoder.AutoSlideShow javascript component. Modifications Made: Added image caching so there's no flicker when changing images Added Start, Stop and Previous methods to allow user/programmatic control of the slideshow Converted to using the DOM to add the Image tag that is used rather than the div.innerHTML property; just because that's the correct way to do it There we have it, one more day and another lunch time (partially)&nbs... [More]