Adnan’s Blog

Hi everyone!

I recently decided to move my blog to a private host. I have updated various aspects of the new blog which is available at

See you there…

I recently came across a very nice jQuery control library called jQuery Tools. The library features the following JavaScript tools :

  1. Tabs
  2. Tooltips
  3. Expose
  4. Overlay
  5. Scrollable
  6. FlashEmbed

So now you are thinking “Whats so great about this? We already have tons of jQuery plugins for this…”. I thought so too.

The striking advantage of this library is that these tools can be combined, extended and styled, giving you potentially unlimited options for creating customized widgets for your web pages. The website also features great and detailed examples to help you get started, and features some of the best practices recommended by Yahoo engineers. [ref : Best Practices for speeding up your website]

During your development, you may notice that your code file contains using directives which are not required by your code. The Visual Studio IDE provides the Organize Usings option to remove/sort these using directives. To access this option, right-click anywhere within your code editor and select one of the sub-menu options for Organize Usings option.

  1. Remove Unused Usings : This option will remove any using directive not required by your code. Note : Please build your application before executing this option to ensure that any required directives are not removed.
  2. Sort Usings : This option will organize your Using directives alphabetically giving precedence to the System name-space.
  3. Remove and Sort : Use this option to execute the above operations together.

Organize Usings

Like most developer I love jQuery and appreciate the intellisense support in Visual Studio. I am very particular about the format for my code and often use the Document Format option of the IDE. What I noticed was that my braces were never placed on new lines, and I wanted to change this. So here’s what you can do :

  1. In the Tools menu, select Options…
  2. Check the Show all settings options
  3. In the Text Editor > JScript choose the Formatting option.
  4. On the right pane, there are two options under the ‘New lines’ section. Check them as per your requirement.

Javascript Formatting

Here’s a small javascript helper to read Url Query String Parameters.

function GetUrlParams()
          var vars = [], hash;
           var hashes = window.location.href.slice(window.location.href.indexOf(‘?’) + 1).split(‘&’);

        for(var i = 0; i < hashes.length; i++)
                hash = hashes[i].split(‘=’);
                vars[hash[0]] = hash[1];
        return vars;

The above function, will read the url, get the query string part i.e from (“?”) and split each paramter by the (“=”) character and create a name value pair allowing us to access the param value using the param name.


For example, if we are have a test.htm in and the url is :

To access the param values we can use something like :

var params = GetUrlParams();



Unlike the normal TextBox, the MaxLength property doesnt work for MultiLine TextBox. Heres a small trick to solve the problem:

<asp:TextBox ID="txtExample" runat="server" TextMode="MultiLine" />
<asp:RegularExpressionValidator ID="revExample" runat="server" 
ControlToValidate="txtExample" ValidationExpression="[\s\S]{1,200}" 
Display="Dynamic" ErrorMessage="Length cannot be greater than 200 characters" />

The above markup validates the revExample TextBox / textarea and limits the max characters to 200. By modifying the regular expressions, we can validate fields for any scenario. If you are looking for some Regular Expressions to get started out, just point your browser to


Visual Studio is filled with nifty tricks, which if leveraged properly in the right situation can make the developers life easy. Consider if you had a looping statement, and wanted to debug it, but only for a particular value. Rather than hitting the breakpoint every time, you can shorten the hits by using a Conditional Breakpoint.

To set a Conditional Breakpoint, right-click the Breakpoint circle and select the Condition option.

Conditional BreakpointYou can then define the condition and additionally select an option to filter the condition for evaluating the condition, or for raising the breakpoint when the value of the expression changes.