Cross browser keypress event handling

Running example on JSFiddle:

$(document).ready(function () {
    $("#TextBox1").live('keypress', function (e) {
        var kCode = e.keyCode || e.charCode; //cross browser check
        //Mozilla and Safari define e.charCode, while IE defines e.keyCode which returns the ASCII value
        if (kCode == 9) {
           $("#TextBox2").focus();
        }
    });
});

JavaScript Madness: Keyboard Events

Load dynamic controls without dll or project references and assign properties

I recently had to load an instance of a specific control within a masterpage base class that had no direct references but would be available at run-time.   Here is how I approached it.

I first used LoadControl via a fully qualified assembly name.  I then used dynamic to set properties to bypass compile time checks:

Control knownControl = FindControl("KnownControl");
if (knownControl != null)
{
    string assemblyName = "Com.YourNameSpace.UI";
    string controlAssemblyName = string.Format("{0}.{1},{0}", assemblyName, "AwesomeControl");

    Type type = Type.GetType(controlAssemblyName);
    if (type != null)
    {
	dynamic control = LoadControl(type, null);
	control.YourAwesomeName = "Awesome Name";
	control.ShowAwesomeName = true;

	knownControl.Controls.Add(control);
    }
}