Chris Pietschmann

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


Using MiniProfiler with SqlDataSource ASP.NET WebForms Control

I recently implemented MiniProfiler into an existing ASP.NET WebForms application that makes use of databinding to the SqlDataSource control. Since the SqlDataSource uses a DbProviderFactory internally, it is fairly simple to exend the control to utilize MiniProfiler through inheritance and overriding a single method of the SqlDataSource. Here’s a very simple class that inherits from the SqlDataSource control and injects MiniProfiler support to be able to profile the SQL query used by the contr... [More]

Simplovation Web.Maps.VE v3.0 Now With FREE Edition!

Today, I just posted the latest Web.Maps.VE v3.0 release. The coolest thing about this new version is that is has a FREE Edition for non-commercial use! Download Web.Maps.VE v3.0 FREE Edition! There are a few new things in this latest release, but the most significant are the following performance updates: Microsoft CDN (Content Delivery Network) Support Added. This helps improve the Bing Maps content delivery speed by up to 82% JavaScript Performance Optimizations. All the JavaScript cod... [More]

Microsoft Killed the Virtual Earth ASP.NET Control

Yesterday, Chris Pendleton officially announced that the Microsoft Virtual Earth ASP.NET Control is now Dead. Frankly, I’ve considered it “dead” for a long time now since it didn’t get updated much, didn’t have a completely full feature support, has a few bugs AND you couldn’t use it within your applications because it was just a Preview (CTP) anyway. There are however a few good things to point out in the light of Microsoft killing its Virtual Earth ASP.NET ... [More]

ASP.NET AJAX: Create a JavaScript Component with Events

In the spirit of my "Mixing OOP and Event Driving Programming" article I posted a couple days ago; this article discusses how to implement the same thing using the ASP.NET AJAX JavaScript Library. Using inheritence (the ASP.NET AJAX way) it is even easier to implement a little Event Driven Model into your client-side, JavaScript classes/components. Event Driven Basics First we'll start by creating a Person class that inherits from the Sys.Component class. Now remember, sin... [More]

Place a StackOverflow badge on your website

Update: has since added the ability to include StackOverflow "Flair" on your own website; basically a "badge" that contains your Name, Avatar, Score and Medal counts within a nice little box. I'm not sure when they added it, but now it's officially supported. And, for reference, my original StackOverflow Badge code is still below: I was thinking it would be cool if you could place a StackOverflow "badge" on your ... [More]

.NET 3.5 SP1: DataContractJsonSerializer Bug

Update 9/16/2008: After too long, I finally tried uninstalling SP1 and reinstalling it and that fixed the issue. I'm glad it's fixed now! I haven't seen any other suggestions for fixing this, and I first tried repairing the installation, but only an uninstall and reinstall fixed it. Hope this helps solves anyone elses headache with this issue.   A few months ago (back in February actually) I blogged showing how to use the new DataContractJsonSerializer to serialize your .NET objects to JSON... [More]

How To Setup Custom Theme Support In ASP.NET MVC Preview 4 using a Custom ViewEngine

Update 2009/03/26: There is an updated version of this code (with improvements) that targets the ASP.NET MVC 1.0 RTW located here:  Update 8/29/2008: I posted a new blog post today that contains updated code for this example that works with the newly released ASP.NET MVC Preview 5. The new code is located here. One option to do theming in ASP.NET MVC is to use the standard ASP.NET Theme fun... [More]

How To Use ASP.NET MVC in Website rather than Web Application Project

I recently started getting to know the ASP.NET MVC Framework (more specifically the Preview 4 release). The first thing I noticed upon installation is that it only comes with a Web Application Project Template. There is no regular ASP.NET Website template. So, I decided to try converting the Web Application Project Template to a regular ASP.NET Website. I actually prefer to use Website projects instead of Web Application projects since it gives a little more flexibility to deploy changes to the ... [More]

C#: Generate WebPage Thumbmail Screenshot Image

There are a few services out there that serve up screenshots of any webpage for you to display on your website. One popular one is Kwiboo; this is the one that DotNetKicks uses. For some time now I've wondered what the easiest way to do this in .NET was, and today I stumbled upon the undocumented WebBrowser.DrawToBitmap method that makes this extremely easy to do. By the way, I stumbled upon the WebBrowser.DrawToBitmap while taking a look at the source code for the WebPreview tool over at SmallS... [More]

ASP.NET: Fix for WebParts + UrlRewriting/UrlMapping Issue

The problem with using WebParts with UrlRewriting (or UrlMapping) is the WebPart PersonalizationProvider uses the path of the page being rendered to save/load the personalization state, not the path that was rewritten that the user sees. So, to fix this you just need to create a custom PersonalizationProvider and override all the methods that reference path, and call the base methods but pass in the path that was requested instead of the path being rendered. Here's a SqlPersonalizationProvider I... [More]

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]

Virtual Earth + ASP.NET AJAX Now Fixed in Safari

A couple months ago I blogged about the fact that using Virtual Earth and ASP.NET AJAX together on the same page caused errors in Safari. There is good new to report back, the latest update to Virtual Earth has fixed this issue. In fact Virtual Earth v6.1 actually includes much better Safari support that previous versions; it actually works correctly in Safari. I found this to be especially helpful since I can now support Safari with my Web.Maps.VE product. What's the catch? I can't... [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]

Some ASP.NET AJAX Tips and Tricks

I've been using ASP.NET AJAX alot for a while now, so I thought I'd share some of the Tips and Tricks that I've learned though my adventures. Lately, all the buzz has been around Silverlight, but I know there are still a lot of devs out there that can benefit from these tips and tricks. UpdatePanel Tips Use UpdateMode=Conditional By setting the UpdatePanel's UpdateMode property to Conditional, it will only update its contents when one of its triggers o... [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]

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

Google Charts API: an ASP.NET 2.0 Server Control

Today, I just saw that Google released their Chart API. Basically, the Google Chart API allows you to dynamically generate charts for use in your web applications. All you do is pass your data in the querystring and an image is returned. This isn't really a service to get too excited about, but it is pretty simple to use. And, it's Free. I decided to code up a small ASP.NET Server Control that uses the Google Chart API to put simple line graph charts on a page. The image on the right is actuall... [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]

Subsite Rewriting HttpModule for ASP.NET

Here's some simple code for easily adding Subsite functionality to an ASP.NET website using UrlRewriting/UrlMapping. Urls are rewritten in the following fashion: ~/jdoe/default.aspx  => ~/default.aspx?site=jdoe ~/jdoe/subfolder/default.aspx => ~/subfolder/default.aspx?site=jdoe And this is all done by the 65 line HttpModule below: [code:c#] using System; using System.Web; /// <summary> /// Summary description for SubsiteRewriteModule /// </summary> public class ... [More]

ASP.NET 2.0: RewritePath breaks HyperLink's ImageUrl in App_Theme file when path with slash is rewritten

Rewriting a path with a slash ("/") in it will cause a HyperLink's image specified in the ImageUrl property within an App_Theme file to not be displayed. This can also lead to a "Cannot use a leading ..." error when running the website within IIS. Here's a screenshot of the issue occuring:   This is kind of a strange bug, since doing the same thing with an Image works just fine. It's only the HyperLink that breaks. I experienced this issue the other day, and it took me a little bit ... [More]

Microsoft to release .NET Framework 3.5 as Shared Source!

Scott Guthrie announced on his blog today, that Microsoft will be releasing the source code for .NET 3.5 as shared source under the Microsoft Reference License (MS-RL). You will also be able to enable debugging support within Visual Studio 2008 for the .NET Framework. This is really cool. I have always used .NET Reflector to peek into the source of the framework, but now I'll actually be able to look at the code itself. More Info:Releasing the Source Code for the .NET Framework Libraries ... [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]

ASP.NET AJAX: Use "custom" objects as Extender Control Properties

I’ve been working with the ASP.NET AJAX Extensions a lot lately, and have been learning a few trick on how to get stuff done. One of the things I’ve learned is how to create a Generic TypeConverter for ASP.NET Ajax to use when serializing my server-side objects to JSON when passing them down to the client-side. Introduction When creating an ASP.NET Extender Control (using ASP.NET AJAX and the AJAX Toolkit) you can add custom properties to your Extender (using the ExtenderCont... [More]

Learn ASP.NET Provider Model By Example via BlogEngine.NET

I was looking through the code of the new BlogEngine.NET project last week, and noticed that it implements the ASP.NET Provider Model. Cool an example I can study! I've been trying to spend some time lately to learn more about design patterns, so this was an interesting find for me. If you look at the code for BlogEngine.NET you'll see that it is a rather simple application that demonstrates a working implementation of the ASP.NET Provider Model that you can learn from. Go check out the code a... [More]

AjaxControlToolkit TabContainer: TabPanel.Visible="False" should not display header text

If you set the visible property of TabPanels within your TabContainer to false, it still shows the Header Text in the page when rendered. What should happen is any TabPanels with Visible set to False should be hidden. A fix for this has been posted to the AJAX Control Toolkits Issue Tracker, but we have to wait for the next release to get the fix in place. Is there a work around? Below is an Inherited class I created using the fix described to allow me to fix this issue myself u... [More]