Sunday, October 08, 2006

I just updated my blog to the new version of dasBlog and hope to blog on a more regular basis.

Life has been busy... Anouncing the arrival of Aaron Martin Robinson. Born August 6th. Aaron's arrival and my marriage to Jennifer are clearly the two biggest events in my life. Oh and how life has changed!

Lots of additional pictures over on my photo site including the birth action shots:

http://photos.binaryocean.com/?path=Aaron

kick it on DotNetKicks.com   Sunday, October 08, 2006 6:56:06 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Wednesday, June 21, 2006

Had a customer ask for this functionality. Easily done. I can see using it in most of my GridView applications. You could modify this to recursively move throught e.Controls and find the first TextBox.

protected void GridViewMain_RowDataBound(object sender, GridViewRowEventArgs e) {

    if (e.Row.RowIndex == GridViewMain.EditIndex && e.Row.RowIndex != -1) {

        const string selectScript = "<script language='javascript'>document.getElementById('{0}').select();</script>";

 

        Control control = e.Row.FindControl("TextBoxQuantity");

        if (control != null) {

            Page.ClientScript.RegisterStartupScript(this.GetType(), "FocusEditTextBox", string.Format(selectScript, control.ClientID));

        }

    }

}

 

kick it on DotNetKicks.com   Wednesday, June 21, 2006 7:29:29 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Friday, March 17, 2006

The compiler is typically pretty smart when it comes to string literals. Take a look at your code with Reflector and the debugger disassembler.

static void Main(string[] args)

{

    string a = "A" + "B" + "C" + "D" + "E" + "F" + "G";

    Console.WriteLine(a);

}

 

//reflector:

private static void Main(string[] args)

{

    string text1 = "ABCDEFG";

    Console.WriteLine(text1);

}

 

//but it not smarter than your application:

static void Main(string[] args)

{

    string a = "A";

    string b = "B";

    string c = "C";

    string d = a + b + c;

    Console.WriteLine(a);

}

 

//reflector:

private static void Main(string[] args)

{

    string text1 = "A";

    string text2 = "B";

    string text3 = "C";

    string text4 = text1 + text2 + text3;

    Console.WriteLine(text1);

}

 

//and now for a slightly different question and answer:

static void Main(string[] args)

{

    string a = "A" + "B" + "C" + "D" + "E" + "F" + "G";

    string b = "ABCDEFG";

}

 

take a look at the debug disassembly and you will see that both a and b are initialized with the same literal:
string a = "A" + "B" + "C" + "D" + "E" + "F" + "G";
00000029 mov eax,dword ptr ds:[0227307Ch]
0000002f mov edi,eax
string b = "ABCDEFG";
00000031 mov eax,dword ptr ds:[0227307Ch]
00000037 mov esi,eax

kick it on DotNetKicks.com   Friday, March 17, 2006 10:02:22 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Tuesday, March 07, 2006

Does your new Dell high resolution LCD display graphics within Internet Explorer that look like this?


Your computer manufacturer has enabled a setting within IE that attempts to scale graphics to their original intended size by correcting for your wide aspect or high resolution display. You can turn it off with the following registry hack. Graphics will now appear smaller but clean.

REGEDIT4
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]
"UseHR"=dword:00000000

Download the Reg files here:
http://download.binaryocean.com/IEUseHR.zip

kick it on DotNetKicks.com   Tuesday, March 07, 2006 10:54:21 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [2]  | 
 Monday, February 27, 2006

This is a bit off topic:

My old Nokia 6xxx series phone gave me many years of service before the seal between the LCD and the outer plastic clear screen finally went. The phone collected lint from my pocket rendering it unreadable in direct sunlight. I could pop off the back and front covers and clean the screen but would only get a few days out of it. Maybe I needed to work on my laundering technique instead? Time for a new phone...

I have always wanted a Microsoft Windows Mobile Smartphone so I decided to give the Cingular 2125 a try. A phone that I could program with the CF and sync with all my Outlook contacts! To top things off, Cingular is currently offering their Media Net unlimited data plan for $20 per month so now I could even read my email. Seemed like a no brainer to me.

At first I really loved the phone. The display is bright and beautiful. The much talked about power button isn't really that bad. You just need to realize that the button is really just a bump on the hard plastic strip that runs across the top of the phone. To push it, push perpendicular to the plastic strip and not the faux button. The strip is attached and hinges slightly at the right hand side of the phone. The faux button is on the left and is more of a guide than anything else. I was able to set up the phone and sync to my back end Exchange server without much effort.

The Dark Side: After using the phone for a day, I found that my average to slightly large hands were just too big for those tiny keys. The phone is almost the same size as my previous Nokia but the screen takes up most of that real estate. I also found that about 35% of the time I would make the wrong selection with the little joy stick (another result of the large screen and small key area.) Lastly, the Media Net access was painfully slow. I was quickly regretting my choice.

I returned the phone and exchanged the 2125 for a Motorola RAZR which seemed like a much better fit for my fingers and hands. I also went with the RAZR because it is the same phone that my wife has and having a single set of chargers and connectors is nice. My only complaint with the phone is that you can't page in the address book and scrolling a contact line at a time is very slow.

One other minor complaint about the RAZR is that Motorola decided to orient the LCD (and front polarization) at 90 degrees to what is normally done. On most of the active LCDs that I have used, the screen gets brighter and darker as you change the angle of tilt by moving the top of the screen closer and further away from you but when you do this on the RAZR, the brightness remains relatively constant. On most LCDs as you move from left to right the brightness remains constant at least until you move way out to one side or the other. Again, my RAZR exhibits exactly the opposite behavior. I notice a subtle difference in the brightness of the image viewed by my left and right eyes. I am guessing that Motorola did this to better handle the "flip" aspect and thus the different vertical viewing angles of the phone?

If Motorola were to put Windows Mobile on the RAZR form factor, they would have a big hit.

kick it on DotNetKicks.com   Monday, February 27, 2006 9:24:19 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [1]  | 
 Thursday, February 16, 2006

Just came across this little generic gem:

string[] input = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };

int[] output = Array.ConvertAll<string, int>(input, delegate(string s) { return int.Parse(s); });

 

I have a number of web.config files that store lists of integers as comma separated strings. This is a clean way to convert it all to an int array. (It is in need of some exception handling.)

 

<appSettings>

      <add key="MachineIDs" value="44,3,43,566" />

</appSettings>

 

private int[] GetConfigIntArray(string key)

{

    string[] values  = ConfigurationManager.AppSettings[key].Split(',');

    return Array.ConvertAll<string, int>(values, delegate(string s) { return int.Parse(s); });

}

kick it on DotNetKicks.com   Thursday, February 16, 2006 10:46:59 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [5]  | 
 Tuesday, January 31, 2006

Seems that everyone is getting into it:

  Microsoft IBM Oracle
Product Name SQL Server Express 2005 IBM DB2 Express-C Oracle Database 10g Express Edition (XE) (beta)
Version 9.0.1399 8.2 10g (beta)
Max DB Size 4 GB Unlimited 4 GB
Max RAM 1 GB 4 GB 1 GB
Max CPUs 1 2 1
Max Users Unlimited Unlimited Unlimited
Instances Unlimited Unlimited 1
Price Free Free Free
  Download Download Download
kick it on DotNetKicks.com   Tuesday, January 31, 2006 4:37:30 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [1]  | 
 Friday, January 27, 2006

This is one that has been driving me crazy for a few weeks. I finally decided to get to the root of it:

I have an ODS control that sits between a GridView and a data class that returns a DataTable. I manipulate the datatable in the ObjectDataSource_Selected event. If my data class throws an exception, I never see it, however I receive a "System.NullReferenceException: Object reference not set to an instance of an object." when attempting to access the Rows.Count property within the ODS Selected event:

protected void ObjectDataSourceMain_Selected(object sender, ObjectDataSourceStatusEventArgs e)

{

    DataTable dataTable = (DataTable)e.ReturnValue;

 

    if (dataTable.Rows.Count == 0) // <- Exception!

    {

        // ...

    }

}

 

The solution involves checking the e.Exception property and throwing the exception when e.Exception is not null. In this case I receive the offending "System.Data.SqlClient.SqlException: Invalid column name 'CcontentID'." exception:

 

protected void ObjectDataSourceMain_Selected(object sender, ObjectDataSourceStatusEventArgs e)

{

    if (e.Exception != null)

    {

        throw e.Exception;

    }

 

    DataTable dataTable = (DataTable)e.ReturnValue;

 

    if (dataTable.Rows.Count == 0)

    {

        // ...

    }

}

kick it on DotNetKicks.com   Friday, January 27, 2006 3:54:10 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [5]  |