Custom key board mapping for Namespace organization in Visual Studio

Visual studio has lot of key board shortcuts for making the things easier. One of the mostly used feature for which IDE doesn’t have key binding is “removing unused namespaces”. I like this feature very much as it makes the code much cleaner. Normally, to make this work we need to right click on the namespaces and navigate to “organize usings ->remove and sort”. We can create a shortcut key with custom key binding as shown below. You can choose any shortcut key as per your convenience but I personally prefer Ctrl+N,O (N-Namespace, O-Organize) as this is the easy one to remember.

To create this, go to Tools->Options->environment->keyboard. By typing “organizeusing” in “Show commands containing” we can see list of IDE commands. Just select the one which ends with “OrganizeUsings.RemoveAndSort” and press the shortcut key you want to assign.

Hope this helps.


Calling JavaScript from

Most of we think that it is very difficult to call a javascript code from
codebehind file in But it is possible with a single line of code….
Let me explain to display a confirmation dialog box in a page…
If we have a button named Button1 then
  in Page_Load  add the following single statement
    Button1.attributes.add("onclick","if (confirm(‘Are you sure to proceed?’)) return true;else return false;")
       That’s it. Our job is done..
Now we can write the server side coding in Button1_Click that shud be executed if user clicks "yes"
      on the prompt. It won’t do the postback if we go with "No" option