Thursday, August 28, 2008

New in Windows Server 2008: Draining for Terminal Services

A new feature in Terminal Services on Windows Server 2008 is server draining. Before you take a terminal server offline, you can have the server stop accepting new connections and wait for existing users to end their sessions. Users can also re-connect to disconnected sessions so they do not lose data.

That's yet another reason for organization to upgrade to Windows Server 2008.

Details on how to do this are available on this MSDN blog page.

Wednesday, August 27, 2008

Thinkpad X200 Tablet Spotted


There has been no word from Lenovo about a tablet version of the Thinkpad X200, but there have been rumors and speculations. Finally, there's been a picture posted of the Lenovo Thinkpad X200t indicating that we could hear from Lenovo sometime soon announcing specs, pricing and, possibly, an availability date.

Tuesday, August 26, 2008

GridView 'Edit' Request With IsPostBack False

This seemed to be a weird one... I was getting two requests from my Page with GridView, one with IsPostBack false and another with IsPostBack true whenever I clicked the Edit image. As I was setting the master page in the PreInit event based on UrlReferrer and IsPostBack (the UrlReferrer is the same as the current page for postback requests - both normal and the weird ones that GridView is causing), this was wreaking havoc on the page.

A possible workaround for the GridView edit-images bug is to use TemplateFields with ImageButtons, or use text instead of images by removing the ButtonType="Image" attribute setting. I got a tip suggesting the use of ScriptManager.GetCurrent(Page).IsInAsyncPostBack instead of IsPostBack.

Sunday, August 24, 2008

Calling Javascript from an UpdatePanel

You've probably used ClientScript.RegisterStartupScript in your ASP.NET application and it works just fine. However, if you try it within an UpdatePanel control, you would notice that it simply doesn't execute.

The solution to this problem is to use ScriptManager.RegisterStartupScript instead. You can call it like so:
ScriptManager.RegisterStartupScript(updatePanel1, updatePanel1.GetType(), "key", "alert('My script');", true);

Digger


If you like playing classic old games or you're simply stuck with a computer that doesn't do Age Of Empires III or World of WarCraft, Digger is the game for you. It is Pacman-like game centered about a digger while can get through dirt by building tunnels and can shoot bullets. The baddies are Nobbins which can go through tunnels and Hobbins which can dig tunnels too. You can finish a level either by eating up emeralds or by killing all the Hobbins and Nobbins. I've put myself on the top of hi-score charts a couple of times, but my sister beat my all-time best score recently. Oh well, at least I rate high on consistency.

Thursday, August 21, 2008

The Force Unleashed demo releases today


Lucas Arts will release a demo of Star Wars: The Force Unleashed on the PlayStation Network and XBox Live Marketplace later today (21st August 2008). The demo features a tutorial and one playable level which involves finding & killing Rahm Kota, a Jedi General who takes over the TIE fighter construction facility.

The final retail version is expected to hit stores on 16th September 2008.

Monday, August 18, 2008

Blogger.com has a new interface

Blogger.com now has a new interface for blog owners to make posts. It's great for people having multiple blogs.


I have some old blogs that I didn't want to delete yet so those are still around on Blogger.com and it clutters up my interface. I wish there was some way to 'Archive' old blogs.

Better performance with declaring strings as constants?

I came across a pretty neat post by Chris Skardon about declaring strings as constants for performance. There is a margin performance increase caused by this, but it offers more of a readability benefit for other developers who would have to maintain your code.

If you're writing your code, then it might be worth putting it in for sections that would be frequently executed but if you're trying to get more performance out of hundreds of lines of old code, you're better off trying out some other optimization technique to cut down execution time.

Wednesday, August 13, 2008

Agile Software Development


Intro to Agile

From: Siddhi, 10 months ago





The Intro to Agile session at Agile Chennai 2007 presented by Bala and myself


SlideShare Link

Tuesday, August 12, 2008

Killer Thinkpad to be announced


The coolest Thinkpad yet will soon be announced by Lenovo. It features a 17" WUXGA display with an integrated camera, 8GB DDR3 memory, Intel Core 2 quad core processor, 2 200GB RAID hard disks, BluRay DVD, Fingerprint reader, 7-in-1 card reader, WLAN 802.11n/Bluetooth/WiMAX, NVidia Quadro FX3700M, a Wacom digitizer and a numeric keypad.

(Source: Geek.com, Gizmodo.com)

Siggraph in Asia

If you've missed Siggraph 2008 in L.A., you can still catch Siggraph Asia 2008 from 10th December 2008 to 13th December 2008 at the Suntec Convention Centre in Singapore. The Siggraph Asia 2009 conference will be hosted in Yokohama, Japan.

OpenGL 3.0 Released

Siggraph 2008 was the stage for the release of the OpenGL 3.0 specification, featuring the GLSL 1.30 sharing language. A list of new features is available on the Kronos site here.

Also released are some extensions to OpenGL 2.1, which brings to older graphic processors some of the features of OpenGL 3.0.

GMail goes down temporarily

GMail was down at about 2pm Pacific Time yesterday. It's up and running now.

GMail has posted an apology for the service outage on the official GMail Blog too.

VS2008 SP1 / .NET 3.5 SP1 released

Visual Studio 2008 Service Pack 1 / .NET 3.5 Service Pack 1 has been released! New features in the service pack include ADO.NET Data Services and the ADO.NET Entity Framework.

You can download an ISO image (831.3MB) from here (follow the link)

Monday, August 11, 2008

Meghan McCain's Blog

John McCain's daughter, Meghan McCain, has been blogging about the McCain campaign. It's more photographs than words... a kind of a show-and-tell, which is a nice change from the all-text blogs that take up most of the blogosphere. Her blog is at:
http://www.mccainblogette.com/

BlizzCon 2008 on 10th & 11th October

If you've missed the trip this year to Siggraph in L.A., you'd better not miss BlizzCon. BlizzCon is a convention organized by Blizzard Entertainment for its games - WarCraft, Diable and StarCraft. It's at the Anaheim Convention Center in California on 10th and 11th October 2008, with tickets priced at $100. BlizzCon is the stage for new releases from Blizzard, concerts and StarCraft/WarCraft gaming tournaments.

You can get some pictures from last year's BlizzCon at:
http://blizzardent.com/blizzcon07/

Top Ten Hacks of 2007


Top Ten Hacks of 2007

From: jeremiahgrossman, 1 day ago



SlideShare Link

ValidatorCalloutExtender requires EnableClientScript set to True

I noticed recently that the a page I created recently had a CalendarExtender that doesn't work. Further investigation revealed that I have a Javascript error that says:
Sys.ArgumentException: Value must not be null for Controls and Behaviors.
Parameter name: element

I figured it must be one of the ValidatorCalloutExtender controls so I disabled all of them and there was no error! I enabled them one-by-one and noticed that only the ValidatorCalloutExtenders associated with a RequiredFieldValidator attached to an FCKEditor control caused the error. Now, an FCKEditor control has nothing to do with the ValidatorCalloutExtender, but I do remember having to set EnableClientScript to false to get the validation working with the RequiredFieldValidator.

I looked up other reports of the Javascript error associated with the RequiredFieldValidator and ValidatorCalloutExtender and those had the EnableClientScript attribute set to false too. I'm guessing that's the cause, but until I get a chance to verify it further, let's just leave it at speculation.

Leonard3Do

You've probably never thought they'd ever be able to make 3D drawing as simple as putting pencil to paper, right? Well, actually, Leonar3Do does just that. Leonar3Do comes with a pair of 3D goggles, a 'stylus' and a pair of sensors to attach onto the monitor.

You can catch a glimpse of it at Siggraph '08, but until then you can read more about it at:
http://www.3dforall.hu

SoftImage XSI

One of the really cool exhibits during Siggraph '08 would be the SoftImage XSI 7. It's a neat 3D modeling and animation product featuring the ICE visual programming interface. Rather than write loads of code, you can just draw nodes indicating what you want it to do. Follow the links on this post to access the video demos.

You can get a trial copy of XSI 7 here:
http://softimage.com/products/xsi/try/

Siggraph 2008 Begins

If you're in L.A., you've probably heard about Siggraph, which is the biggest conference on computer graphics technologies. You would find new hardware, graphics & animation software, research presentations, courses and a job fair at the event. The best thing you can bring back from Siggraph is the DVD set of the event, which contains videos of paper presentations and demos of some of the software presented at Siggraph.

The conference is from 11th August to 15th August, while the exhibition is from 12th August to 14th August. Both events are at the Los Angeles Convention Center.

Robot Competition Events 2008-2009

I found a list of Robot exhibitions and contests from April this year till April next year. Check it out at:
http://www.robots.net/rcfaq.html

PS: This is my 150th post!!!

Sunday, August 10, 2008

Javascript: Warn If Overflow

I recently came across a requirement to provide a warning to the user if the text entered in a text box exceeds the display area in a DIV, and found and old script I cooked up for it. An issue with setting the maximum length for the text box is that the 'W' and 'i' characters don't occupy the same space width variable-width fonts. I though it would be possible to measure the width of the text when the text is placed within a container using the offsetWidth property and I wrote up a little function:

function getSize() {
var divNitinz = document.getElementById('divNitinz');
var txtName = document.getElementById('txtName');
divNitinz.style.display = 'inline';
divNitinz.innerHTML = txtName.value;
var txtWidth = divNitinz.offsetWidth;
divNitinz.style.display = 'none';
return txtWidth;
}


I then created another function to get this value and compare it with the DIV in which I wanted to display the text and that looks like this:

function checkSize() {
var divDisplay = document.getElementById('divDisplay');
var txtName = document.getElementById('txtName');
if (divDisplay.offsetWidth <>
alert('Text overflow');
divDisplay.innerHTML = 'Text width: ' + getSize() + ' Display width: ' + divDisplay.offsetWidth;
} else {
divDisplay.innerHTML = txtName.value;
window.status = 'Text width: ' + getSize() + ' Display width: ' + divDisplay.offsetWidth;
}
}


My HTML is pretty simple:

<form>

<input type="text" name="txtName" id="txtName" onkeyup="checkSize();" />

<input type="text" name="txtName" id="txtName" onkeyup="checkSize();" />


<span id="divNitinz" style="display: none;"></span>
<div id="divDisplay" style="width: 120px; background-color: #FFFF99;"></div>
<input type="button" onclick="checkSize();" value="check" name="btnCheck" />
</form>

You've probably noticed the setTimeout that I've defined on the onkeydown event. I use it to get the text after the key has taken effect. I tried the onkeypress event before using onkeydown and the difference is the keypress event doesn't occur when you press backspace while the keydown event does, which makes it the better of the two.

If you've got any enhancements to this script or a better way to do detect overflow, let me know and I'll post it up here.

Saturday, August 9, 2008

SMTP settings in config

Did you know that you can move the SMTP settings of your .NET app to the configuration file too? No, I don't mean reading out of AppSettings and writing code to read from it again - it's a .NET feature.

When you instantiate the SmtpClient class, you can call the contructor that accepts no parameters. This causes a read from the config file, which has the SMTP settings defined as follows:

<?xml version="1.0"?>
<configuration>
<system.net>
<mailSettings>
<smtp>
<network host="" port="" userName="" password=""/>
</smtp>
</mailSettings>
</system.net>
</configuration>

It's great for the system administrators too as they now have a standard way to configure SMTP, provided that developers decide to use this feature.

EDIT: I'm sorry about the missing code extract... Blogger.com removed the XML tags from the post.

The 7 Dirtiest Jobs in I.T.

InfoWorld.com has an article on the 7 dirtiest jobs in I.T. linked from their article on the return of COBOL. They are:

7. Legacy Systems Archaeologist
Supporting legacy systems, such as those written in COBOL

6. Help Desk Zombie
Desktop support involving interaction with end users

5. On-site Reboot Specialist
Handling end-user issues by getting into dusty, less-than-hospitable environments; usually involves travelling even in summer heat

4. Interdepartmental Peace Negotiator
I.T. project managers mediating between I.T. teams and clients, although sometimes it is within the same firm

3. Enterprise Espionage Engineer (Black Ops)
Social engineering to get access to data or something malicious, with a white hat of course

2. Datacenter Migration Specialist
Systems administration & networking staff moving around dusty servers

1. Sludge Systems Architect
Systems administrators who have to put their hands into sewage sludge

You can read more at:
http://www.infoworld.com/article/08/03/10/11FE-dirty-tech-jobs_1.html

GooglePages to GoogleSites

If you've tried signing up for GooglePages recently, you've probably noticed Google has stopped new signups for GooglePages and has advised users to signup on Google Sites instead. It seems very Sharepoint-like and we have the ability to restrict the viewers and editors for the site too. Do give it a try at http://sites.google.com

Posting to WebForm via .NET

Posting data to a form via .NET code is quite simple, thanks to the HttpWebRequest class. You need to follow these steps to accomplish this:

  1. Create an HttpWebRequest object, and set the Method and ContentType properties.
  2. Get the data into a string in the form argument1=value1&argument2=value2. This has to be URL encoded, although you can get away without it if you don't have spaces or any special characters.
  3. Get the RequestStream for the HttpWebRequest object and write the data (parameters to be posted to the form) to it.
  4. Get the HttpWebResponse object for the request.

Here's a code sample:
/*
"using System.Net;", "using System.Web;", "using System.IO;" and "using System.Text;" should be added to the top of your code
*/

WebRequest wReq = HttpWebRequest.Create("http://localhost/Form1.aspx");
wReq.Method = "POST";
wReq.ContentType = "application/x-www-form-urlencoded";
string formData = string.format("name={0}&phone={1}", HttpUtility.UrlEncode("Nitin Reddy"), HttpUtility.UrlEncode("+9715015456"));
byte[] formDataBytes = ASCIIEncoding.ASCII.GetBytes(formData);
wReq.GetRequestStream().Write(formDataBytes, 0, formData.Length);
string returnData = new StreamReader(wReq.GetResponse().GetResponseStream()).ReadToEnd();

Friday, August 8, 2008

SQL Server 2008 RTM



MS SQL Server 2008 just went Release-To-Manufacturing. It's pretty exciting because it features the MERGE statement, the FileStream data type and, the single most cool feature, array parameters.

There's a lot of code out there using a CSV string as a parameter to obtain multiple parameters. Splitting the CSV string in T-SQL is very inelegant and reduces performance a bit. Native support for array parameters will lead to improved performance and will also get the ORMs out there to generate more efficient code, as they usually avoid the CSV string trick and go with dynamic SQL leading to parsing overhead for the SQL statement.

System.Data.Linq.Table: Beta 2 to RTM

If you've been following Microsoft technologies for a while, you probably noticed that when the technology goes into RTM, there are changes in method names and syntax (remember the exception handling syntax with SQL Server 2005 T-SQL in beta?). The same goes for LINQ.

When trying out code samples from the Beta 2 days, you'll probably want to note the following change to the method names of the System.Data.Linq.Table class:




The Add, AddAll, Remove and RemoveAll methods have been renamed to InsertOnSubmit, InsertAllOnSubmit, DeleteOnSubmit and DeleteAllOnSubmit, respectively. This is mostly because database developers look for methods with names that resemble the SQL statements (SELECT, INSERT, UPDATE, DELETE) and because these methods do not immediately add or remove the data from the table like you would expect if you've been working with collection types.

If you haven't updated your source code yet, you'll end up with the following compilation error:
System.Data.Linq.Table does not contain a definition for 'Add' and no extension method 'Add' accepting a first argument of type System.Data.Linq.Table could be found (are you missing a using directive or an assembly reference?)

A New Interface For Del.icio.us

Last week, Del.icio.us got a make-over. Yahoo decided to change the interface and the social bookmarking site just got a flavor of Web 2.0. Why Yahoo, you're wondering? Yeah, they took over Del.icio.us way back in December 2005. It didn't seem very Yahoo-ish so users had no way to tell. The site has also been re-branded from "del.icio.us" to "delicious".


The new interface reminds me a bit about Digg, with the number of users who bookmarked a link. Although they now claim that the system has been designed for efficiency and to handle a greater load, I can't really tell because as soon as I tried to go to the settings page, they freakin' blocked me! (see screenshot below)


I guess it'll take them a while to iron out the bugs. I wonder why they wanted to fix something that wasn't broken, especially since they didn't Yahoo-ize it.

Thursday, August 7, 2008

TextChanged event and ViewState

If you're coming from the word of traditional forms where the page containing form fields contains plain HTML and posts to a server-side script, you probably know that the textbox doesn't need ViewState to post data to the page.

However, you do need ViewState for the TextBox to properly track changes to the textbox value. This effects how the TextChanged event is fired for the textbox.

When ViewState is enabled:
The TextChanged event is fired when a change to the value is followed by a postback. Subsequent postbacks do not cause the event to fire.

When ViewState is disabled:
The TextChanged event is fired on all postbacks if the value is changed from it's initial value (such as the value set with the Text property).

Tuesday, August 5, 2008

ASP.NET: A DropDownList cannot have multiple items selected

For those of you looking at the title, I know that a drop down list cannot have multiple items selected. That's why we use a dropdown list - to get the user to select one item from a bunch of different values.

The problem I've been experiencing is the exception that ASP.NET throws to me when I add a blank item to the dropdown list with a:
ListItem lstBlankItem = new ListItem();
lstBlankItem.Selected = true;
ddlDropdown.Items.Add(lstBlankItem);


...and I then follow that up with a:
lstBlankItem.SelectedValue = 83;

ASP.NET doesn't automatically changed the Selected property of the ListItem added earlier to false when I set the SelectedValue to a different value. I guess it's one of those things the guys at Microsoft thought was gimmick-y ("Look, boss, we can tell when a stupid developer uses our framework to select two items in a listbox"). It's going to shoot them in the foot when some development lead finally gives in to the urge to move to Java.

I recently read that if you have multiple dropdown lists bound to the same datasource and each of the dropdown lists have different items selected, this could be the result. I've yet to try it out though.

Monday, August 4, 2008

string ToTitleCase

We have a string.ToUpper and string.ToLower, but did you know that we've also got a ToTitleCase? It's not defined in the String class, but rather in the TextInfo class. Here's an example:

string lhello = "hello woRld";
lhello = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(lhello);
Console.WriteLine(lhello); //Hello World

Blackle:An eco-friendly Google


Blackle is a web front-end to the Google search engine, that we have all come to know and love. The aim of Blackle is to help the thousands of users from around the world save on energy. How does it do this? Here's a simple explanation from the Blackle website:
Blackle saves energy because the screen is predominantly black. A given monitor requires more power to display a white (or light) screen than a black (or dark) screen.

If you use a CRT monitor (or a large plasma screen), you would save a lot from using Blackle instead of the Google interface. With an LCD panel, you would be able to cut down battery usage by a bit.

Anyway, check out Blackle at:
http://www.blackle.com

Forcing a re-query with LLBL Gen Pro Data Source

I used a DataList control for an ASP.NET page, instead of the GridView that we've all come to know and love, and I stumbled across the fact that the DataList doesn't handle the Edit, Update and Delete events automatically like the GridView does. Okay, I admit it, I haven't been doing any hands-on U.I. development for a long long time.

So, I write my custom code to manipulate data with the DataList and oddly enough, the code to modify the data executes but the new data doesn't appear. I guessed the LLBLGen Data Source control must have something to do with it - those things are really lazy little creatures that do not do things unless they absolutely have to so I set the Refetch property to true before the DataBind. That fixed it!

Friday, August 1, 2008

The Case of the 3 Timers

When you ask a Windows Forms developer about the Timer class, you'll get to hear all about the glories of the System.Windows.Forms.Timer class. A Windows Service developer will go on and on and on about the System.Timers.Time. Finally, the fresh graduate who read about the Timer class in .NET will tell you about the System.Threading.Timer class. There are three different classes with each having a purpose of it's own.

System.Windows.Forms.Timer

This is the timer class most Windows Forms application developers would use. The handler code executes within the same thread as the form within which it is placed via the WM_TIMER window message.

The downside of using this class is that it will be unable to raise events while the User Interface thread is busy, such as when calling Thread.Sleep.

System.Timers.Timer

This timer class is included in the components toolbox. It cannot access Windows Forms controls directly and provides a SynchronizingObject property which you can set to an instance of the form to run the handler code in the same thread on which the form instance was created.

Unlike the System.Windows.Forms.Timer class, this class is able to queue events for execution.

System.Threading.Timer

For a light-weight timer class, the System.Threading.Timer class fits the bill. It cannot write to Windows Forms controls so you would have to use the BeginInvoke method of the form for any interaction with the U.I. For writing re-usable code, you can check the InvokeRequired property - if true, you would have to use BeginInvoke.

The members of this timer class are not thread-safe, which is odd considering that it resides within the System.Threading namespace.

China unblocks websites

China has restored access to several websites that were previously blocked, including news websites and the websites of human rights groups, to provide access to information for journalists covering the Olympic Games. This also provides access for other Internet users.

Is it a change in China's policy or is it a friendly gesture toward international journalists?