Weblog Of Nirandas | home

Developer From INDIA

Annoying the user: Please enter numbers only

clock August 27, 2008 11:24 by author

Everyone of us sometime or other had to restrict the user from entering non-numeric values in to a text field. We normally validate user input when user presses the submit button or when the user leave the input field and display the error message in a span or using alert() javascript function.

However what will happen if we validate user input as the user is typing in the field and also use a alert box to display error message instead of showing it in a span?

Please do not do this ever and annoy your dear visitors and make them ask "who developed this crap?".

In the recent past, I had to fill out a form where I was supposed to enter my phone number and they ware using this annoying technique. Now I mistyped my number and the validation script throws an alert(). I press "OK" by pressing space bar and to silence my screen reader, I pressed "ctrl". You can guess the result. The alert comes again!

So, we developers should never try to annoy our users using this kind of unnecessary tricks, instead we should make our user interfaces as smooth as possible to use for both normal users and users with special needs.

Never try to outsmart your visitors because situation will outsmart us! And never try to lock the user's keyboard because it's their keyboard and they are free to use it as they like.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Be the first to rate this post

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


displaying html or other files using their default application

clock August 25, 2008 15:27 by author

Sometimes, we may want to show user a readme file or start any application or open any document on the system. For openning any file with their default file open handeler, we just have to use following one liner.

System.Diagnostics.Process.Start(@"d:\niran\readme.htm");

You can pass the path to any file or path to any executable and it will be opened like when you double-click on it in windows explorer. In fact, you can also open web addresses using this method in the default browser of the system.

System.Diagnostics.Process.Start(@"http://www.nirandas.com/blog/");

Passing arguments

We can also pass arguments while starting any executable using the second parameter.

System.Diagnostics.Process.Start(@"mysql.exe",@"-u root -p");

Here we are starting the application "mysql" and passing it "-u root -p" as command line arguments. The Process.Start() method also takes many other parameters other than discussed here allowing us more finer controll.

You can easily launch files/applications using this one line of code. Enjoy,

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Be the first to rate this post

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


Create datetime range with custom interval

clock August 23, 2008 12:48 by author

In this post I will show a method using which we can create datetime ranges. This method is not specific to the datetime, instead it can be used with any type including int, long etc. There is a new method in .net framework 3.5 using which we can easyly create integer ranges. For example.

foreach(int i in Enumerable.Range(1,10))Console.Write(i);

However, in this post I will show how we can create integer ranges and datetime ranges with custom intervals etc.

More...

Be the first to rate this post

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


Linq without using query syntax

clock August 19, 2008 10:41 by author

In this post an possibly few upcoming posts, I will be playing with linq without using the query syntax provided by the language. Most of the example/articleson the linq uses query syntax provided by the language and the keywords like from, where, select etc for working with linq queries. Yes, using the querysyntax is more readable and easy, however, it should be interesting to learn how to work with linq without the syntactic sweetness provided by the C# andvb.

More...

Be the first to rate this post

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


site news: layout changes and wordpress upgrade

clock August 17, 2008 16:37 by author

Today I upgraded the wordpress from 2.51 to 2.61 and also made some layout changes to the other section of the site.

I been using wp 2.51 from the very beginning of this site and didn't upgrade to wordpress 2.6 when it was released. But finally, I decided to upgrade my blog to the latest wordpress version.

and the layout changes to the other parts of the site was to modify the design to match the wordpress default theme. Also I removed the about page and transferred the contents of it to the homepage. As I am not a design person by any means, the responsibility of doing it cleanly and making sure that it looks nice was entrusted upon my brother.

Also, the new upgrade to wordpress 2.61 doesn't break the txcaptcha. The txcaptcha logical captcha protection is working very well.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Be the first to rate this post

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


Displaying time in relative format

clock August 6, 2008 05:36 by author Nirandas

 

Many websites specially forum sites display time relative to the current time as "3 Hours 25 Minutes ago", "30 Seconds ago" etc. In this post I will show a method using which we can convert datetime into descriptive relative time string.

The method takes 2 parameters 1. the time to process, 2. the time to which the output will be relative. Usually it is DateTime.UtcNow. There is also an overload which only takes the time to process where the second parameter defaults to DateTime.UtcNow. Let us see some sample output of this function.

More...

Currently rated 5.0 by 1 people

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


Who Am I?

I am Nirandas - a developer from INDIA

Sign in