Microsoft Most Valuable Professional

Chris Pietschmann

An MVP From Wisconsin

Things I learned about Software WHILE NOT in College

This is a reply to Scott Hanselman's post "Three Things I Learned About Software WHILE NOT in College", except I'm not listing three things I learned IN College because it didn't happen (yet anyway).

Things I Learned about Software While Not in College

  1. If it works, don't monkey with it. You'll just break it and then have to rewrite it
  2. Even though your main job is programming, you still have to deal with people. You may even have to deal with clients too.
  3. There are times when purchasing a component is the best thing to do. You don't always have to reinvent the wheel.
  4. Not all code is pretty, especially when fixing legacy code.
  5. A college degree isn't as important as everyone thinks (at least in the software business); it doesn't mean you really know how to write code. It only means you know how to learn.

 

Be the first to rate this post

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

Categories: General
Posted by crpietschmann on Saturday, June 30, 2007 2:44 PM
Permalink | Comments (1) | Post RSSRSS comment feed


Add iPhone style flicking support using JavaScript

I've been testing some of my code lately in Firefox 3.0 and along with all the iPhone hype, I thought I'd write up some simple JavaScript code that allows me to enable iPhone style flicking support within my own apps.

Go check it out, it's actually pretty neat! And, it's entirely HTML and JavaScript code.

It currently only works in Safari 3.0, Internet Explorer 7 and the Apple iPhone. Well, hopefully the iPhone, I don't have one to test it on.

View Sample and/or Download Code

Be the first to rate this post

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

Categories: General
Posted by crpietschmann on Saturday, June 30, 2007 2:12 PM
Permalink | Comments (0) | Post RSSRSS comment feed


.NET 3.5: How to Convert from one TimeZone to another

The ability to convert directly from one timezone to another is coming (finally!) in .NET 3.5 via the addition of the System.TimeZoneInfo object.

Example C# Code:
DateTime oldTime = new DateTime(2007, 6, 23, 10, 0, 0);
TimeZoneInfo timeZone1 = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");
TimeZoneInfo timeZone2 = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
DateTime newTime = TimeZoneInfo.ConvertTime(oldTime, timeZone1, timeZone2);

Currently rated 5.0 by 1 people

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

Categories: General
Posted by crpietschmann on Saturday, June 23, 2007 11:46 AM
Permalink | Comments (2) | Post RSSRSS comment feed


Email/Website Outage - 06/22/2007

Good News: The website, Pietschsoft.com, seems to be back up.

Bad News: Email still seems to be down.

Here's the deal: My hosting provider, http://discountasp.net, got hit with a DDOS attack and consiquently my email and website were virtually completely down yesterday and today. Yesterday it was spotty, and today totally down. The outage was so bad it brought down their entire data center, including the http://discountasp.net website.

Be Aware: If you emailed me from Thursday morning until ? (I'm not sure when exactly my email will be fully functioning again), please resend when to get a chance or followup to make sure I got it. Thanks!

I'll update this post when/if my site and email status changes.

UPDATE 6/23/07: Ok, it seems as though both the website and email are both up and normal again. Hopefully it stays this way.

Be the first to rate this post

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

Categories: General
Posted by crpietschmann on Friday, June 22, 2007 3:20 PM
Permalink | Comments (1) | Post RSSRSS comment feed

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 ExtenderControlProperty attribute) that get passed down to the client. Well, this is really cool and all, but you are restricted to using the “standard” variable types (string, int, bool, etc.); unless of course you want to create your own custom TypeConverter to convert your custom objects to JSON.

How do I create and use a JSON TypeConverter?

and, do I need to create a separate one for each of my “custom” objects? First off, it’s pretty simple, and secondly, you can create “generic” TypeConverter that will work with virtually all your objects.

Step 1: Create a new Extender Control (http://ajax.asp.net/ajaxtoolkit/Walkthrough/CreatingNewExtender.aspx)

Step 2: Create out “generic” TypeConverter to use with our object. Yes, this is really all the code necessary to create the “generic” TypeConverter; all the serialization is actually done for us by the System.Web.Script.Serialization.JavaScriptSerializer object.

public class GenericTypeConverter : TypeConverter
{
    public override object ConvertTo(ITypeDescriptorContext context, 
       System.Globalization.CultureInfo culture,
        object value, Type destinationType) 
   {
        JavaScriptSerializer jss = new JavaScriptSerializer();
        string s = jss.Serialize(value);
        return s;
    }
}

Step 3: Create your “custom” object that we want serialized and passed down to the client, and set the TypeConverter attribute to point to our GenericTypeConverter. In this example I’m using a Person object to keep things simple.

[TypeConverter(typeof(GenericTypeConverter))]
public class Person{
    private string _FirstName;
    public string FirstName
    {
        get { return _FirstName; }
        set { _FirstName = value; }
    }
     private string _LastName;
    public string LastName
    {
        get { return _LastName; }
        set { _LastName = value; }
    }
}

Step 4: Add our Person property to the ExtenderControl

Step 5: Add the code that deserializes our object on the client. Add the following line of code to the “initialize” method of your ExtenderControl’s behavior javascript file:

[code:c#] 

if(this._myPersonValue!=null){
this._myPersonValue=Sys.Serialization.JavaScriptSerializer.deserialize(this._myPersonValue);
}

Step 6: Acces our Person object properties on the client

[code:js] 

alert("The full name of my person is:\n"    + this._myPersonValue.FirstName + " " + this._myPersonValue.LastName);

Conclusion

Even though this ends up being a very simple thing to do, it took me a lot of time (a few months ago) to figure out since there aren’t very many articles out there on how to do stuff with ASP.NET AJAX.

I also kept this article pretty simplistic, since I’m offering the complete solution for download and code always speaks for itself.

Download Sample Code: CustomJSONTypeConverter.zip

Be the first to rate this post

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

Tags:
Categories: asp.net | General
Posted by crpietschmann on Saturday, June 16, 2007 2:53 PM
Permalink | Comments (7) | 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