# Sunday, February 15, 2009

I just received the confirmation to the exam i did a few weeks ago:

MCPD(rgb)_1259

Sunday, February 15, 2009 2:02:06 PM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Wednesday, February 04, 2009

I’m currently at a customer in Hannover and was asked how to change the background color of a textbox from the client side validation method called by a CustomValidator control.

Here is a sample how to access the pages validation properties including the one from the custom validator:

function validateRequired(sender, args)
{
    if (args.Value == null) return;
    if (args.Value.length > 0) return;

    args.IsValid = false;

    var txt = $get(sender.controltovalidate);
    if (txt)
    {
        txt.style.backgroundColor = '#ff0000';
    }
}

I wrapped the stuff in a server control derived from the custom validator control:

public class RequiredValidator
    : CustomValidator
{
    protected override void OnInit(EventArgs e)
    {
        var ctrl = Parent.FindControl(ControlToValidate);
        if (ctrl == null)
        {
            throw new InvalidOperationException(
                "ControlToValidate not found.");
        }
        var txt = ctrl as TextBox;

        if (txt == null)
        {
            throw new InvalidOperationException(
                "ControlToValidate is not a textbox.");
        }

        if (!Page.ClientScript.IsClientScriptBlockRegistered(
            typeof(CustomValidator), "RequiredValidator"))
        {

            Page.ClientScript.RegisterClientScriptBlock(
                typeof(CustomValidator),
                "RequiredValidator",
                string.Concat(
                    "<script type=\"text/javascript\">\n//<![CDATA[\n",
                    Resources.RequiredValidator,
                    "\n//]]>\n</script>"));
        }
        base.OnInit(e);
        ClientValidationFunction =
            string.Concat(
                "validateRequired");
        ServerValidate += RequiredValidator_ServerValidate;

        EnableClientScript = true;
        ValidateEmptyText = true;
    }

    private void RequiredValidator_ServerValidate(
        object source,
        ServerValidateEventArgs args)
    {

        var ctrl = Parent.FindControl(ControlToValidate);
        if (ctrl == null)
        {
            throw new InvalidOperationException(
                "ControlToValidate not found.");
        }
        var txt = ctrl as TextBox;

        if (txt == null)
        {
            throw new InvalidOperationException(
                "ControlToValidate is not a textbox.");
        }

        if (!string.IsNullOrEmpty(txt.Text)) return;

        txt.BackColor = Color.Red;
        args.IsValid = false;
    }
}

Wednesday, February 04, 2009 9:42:52 PM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Wednesday, January 28, 2009

Nicolas.Goetz 
clip_image001

My good friend Nicolas Goetz has just started to work as International Account Manager (DE, AT … up to Asia) for famous and well known telligent. The guys around Rob Howard are the creators of “Community Server” (the stuff that runs e.g. www.asp.net and loads of other community sites).

Nice move, Nic. Wish you all the best.

Wednesday, January 28, 2009 9:55:19 PM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Thursday, January 08, 2009
Thursday, January 08, 2009 8:38:34 PM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Monday, January 05, 2009

image
The best time to produce loads of code is when It’s cold outside …

Life | Misc
Monday, January 05, 2009 11:44:42 PM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Wednesday, December 24, 2008

That's all folks.

Wednesday, December 24, 2008 5:55:46 PM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Saturday, December 06, 2008

I'm currently working on a project together with Jürgen Bayer (autor of the C# 2008 Codebook and the Visual C# 2008 Kompendium) that makes use of a lot of dependency injection. The configuration files are blown with fully qualified assembly names but how do you get them? Working for instance with custom providers for ASP.NET membership, ASP.NET profile or ASP.NET roles gets you in the same circumstances. In the past I fired up Red Gate's Reflector and loaded the needed assembly to copy the name. I like Reflector but that approach becomes pretty annoying. So I fired up my IDE and hacked down the following peace of code:

using System;
using System.Reflection;
using System.Windows.Forms;
using Microsoft.Win32;
 
namespace devcoach.Tools.AssemblyNameReader
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            // Install shell extension ...
            if (args == null || args.Length == 0)
            {
                using (var regkey =
                    Registry.CurrentUser.OpenSubKey("Software\\Classes", true))
                {
                    if (regkey == null) return;
                    using (var dllFileKey = regkey.CreateSubKey("dllfile"))
                    {
                        if (dllFileKey == null) return;
                        using (var shellKey = dllFileKey.CreateSubKey("shell"))
                        {
                            if (shellKey == null) return;
                            using (var readAsmNameKey =
                                shellKey.CreateSubKey("ReadAssemblyName"))
                            {
                                if (readAsmNameKey == null) return;
                                readAsmNameKey.SetValue(
                                        string.Empty,
                                        "Copy full name to clipboard...");
 
                                using (var commandKey =
                                   readAsmNameKey.CreateSubKey("command"))
                                {
                                    if (commandKey == null) return;
                                    commandKey.SetValue(
                                        "",
                                        string.Concat(
                                            "\"",
                                            Application.ExecutablePath,
                                            "\" \"%1\""));
                                }
                            }
                        }
                    }
                }
                return;
            }
 
            Assembly assembly = null;
            try
            {
                assembly = Assembly.LoadFile(args[0]);
            }
            catch(Exception){}
 
            if (assembly == null)
            {
                MessageBox.Show(
                    "Error loading assembly...",
                    "Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }
            var name = assembly.FullName;
            if (string.IsNullOrEmpty(name)) return;
 
            Clipboard.SetDataObject(name, true);
        }
    }
}

Now I can use the a right click on any assembly to copy its fully qualified name to my clipboard.

image

Saturday, December 06, 2008 9:25:46 PM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Friday, December 05, 2008

Kostja invited Michael and me to speak at the next event of the .net user group in Frankfurt (Germany). We'll show some real project implementations and tell stories from the technology and architecture trenches.

The event will be hosted at Microsoft in Bad Homburg. Further details can be found here...

Friday, December 05, 2008 3:06:07 PM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Wednesday, November 12, 2008

image 

The user group met today at netzkern, a company in Wuppertal specialized in .net development and SiteCore - thanks the venue and drinks! Thanks to Matthias for the pic!

This time we had "Sliverlight 2 in the real world" as a topic presented by Florian Kruesch. He presented new visual features as well as use cases and projects he's working on. Because he didn't touch the non-visual stuff like Isolated Storage he invited me to show something that I've build with the bits:

The "Silverlight Cache" for javascript - most commonly used to cache json returned by web services.

image

A lovely way to reduce traffic :-)

Wednesday, November 12, 2008 10:23:58 PM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Monday, October 27, 2008

image

The first day of PDC is almost gone. I met my former Boss Clemens Vasters had a nice conversation during lunch with John Lam and "a guy with a blue shirt" that I'm not allow to cite here :-).

image

Micheal Willers, Ron Jacobs and I talked about SOA, Dublin, OSLO and the sometimes hard job trying to explain people the problems they will have in the feature (commonly known as archtecture :-P).

image

I was a bit disappointed by the "ASP.NET 4.0 roadmap" because I expected more "visions" and ideas -  Phil Haack showed mostly stuff that is available today (actually really today on codeplex...).

Monday, October 27, 2008 11:22:20 PM (W. Europe Standard Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  |