March 2012 - Posts

Windows 8 Consumer Preview Keyboard Shortcuts

The Windows 8 Consumer Preview is now available for public download, and it offers a very different experience from what Windows users are accustomed to. However, while the operating system is optimized for touchscreen input, that doesn't mean Microsoft forgot about users who are confined to traditional keyboards and mice.

In fact, the Windows 8 Consumer Preview supports a ton of keyboard shortcuts to help make input and interaction a little easier. Some of the new shortcuts are touchscreen-related, such as pressing Windows-O to lock the orientation of the device, while others relate to new features, such as pressing Windows-C to open the Charms bar.

Below is a chart of the keyboard shortcuts we know about, including shortcuts unchanged from Windows 7, as well as a list of brand-new shortcuts. If you're using Windows 8 with a keyboard and mouse or laptop touchpad, these will go a very long way toward improving your experience.


Hotkeys unchanged from Windows 7
Key combinationWindows 7 functionality
Windows Display or hide the Start menu.
Windows-Left Arrow Dock the active window to the left half of the screen (does nothing to Metro-style applications).
Windows-Right Arrow Dock the active window to the right half of screen (does nothing to Metro-style applications).
Windows-Up Arrow Maximize the active window (does nothing to Metro-style applications).
Windows-Down Arrow Restore/minimize the active window (does nothing to Metro-style applications).
Windows-Shift-Up Arrow Maximize the active window vertically, maintaining width (does nothing to Metro-style applications).
Windows-Shift-Down Arrow Restore/minimize the active window vertically, maintaining width (does nothing to Metro-style applications).
Windows-Shift-Left Arrow Move the active window to the monitor on the left (does nothing to Metro-style applications).
Windows-Shift-Right Arrow Move the active window to the monitor on the right (does nothing to Metro-style applications).
Windows-P Display projection options.
Windows-Home Minimize all nonactive windows; restore on the second keystroke (does not restore Metro-style applications).
Windows-number Launch or switch to the program located at the given position on the taskbar. (Example: Use Windows-1 to launch the first program.)
Windows-Shift-number Launch a new instance of the program located at the given position on the taskbar.
Windows-B Set focus in the notification area.
Windows-Break Display the System Properties dialog box.
Windows-D Show the desktop; restore on the second keystroke (does not restore Metro-style applications).
Windows-E Open Windows Explorer, navigated to Computer.
Windows-Ctrl-F Search for computers (if you are on a network).
Windows-G Cycle through Windows Desktop Gadgets.
Windows-L Lock your computer (if you're connected to a network domain), or switch users (if you're not connected to a network domain).
Windows-M Minimize all windows.
Windows-Shift-M Restore minimized windows to the desktop (does not restore Metro-style applications).
Windows-R Open the Run dialog box.
Windows-T Set focus on the taskbar and cycle through programs.
Windows-Alt-Enter Open Windows Media Center. Note that Windows Media Center must be installed for this key combo to function; in many Windows 8 builds, it is not present.
Windows-U Open Ease of Access Center.
Windows-X Open Windows Mobility Center.
Windows-F1 Launch Windows Help and Support.
Windows-N Create a new note (OneNote).
Windows-S Open screen clipper (OneNote).
Windows-Q Open Lync. Note that in Windows 8 the Search function overrides this key combo.
Windows-A Accept an incoming call (Lync).
Windows-X Reject an incoming call (Lync). Note that this key combo does not function if Windows Mobility Center is present on the machine.
Windows-Minus Zoom out (Magnifier).
Windows-Plus Zoom in (Magnifer).
Windows-Esc Close Magnifier.

New hotkeys for the Windows 8 Consumer Preview
Key combinationWindows 8 functionality
Windows-Space Switch input language and keyboard layout.
Windows-O Lock device orientation.
Windows-, Temporarily peek at the desktop.
Windows-V Cycle through toasts.
Windows-Shift-V Cycle through toasts in reverse order.
Windows-Enter Launch Narrator.
Windows-PgUp Move the Start Screen or a Metro-style application to the monitor on the left.
Windows-PgDown Move the Start Screen or a Metro-style application to the monitor on the right.
Windows-Shift-. Move the gutter to the left (snap an application).
Windows-. Move the gutter to the right (snap an application).
Windows-C Open the Charms bar.
Windows-I Open the Settings charm.
Windows-K Open the Connect charm.
Windows-H Open the Share charm.
Windows-Q Open the Search pane.
Windows-W Open the Settings Search app.
Windows-F Open the File Search app.
Windows-Tab Cycle through apps.
Windows-Shift-Tab Cycle through apps in reverse order.
Windows-Ctrl-Tab Cycle through apps and snap them as they cycle.
Windows-Z Open the App Bar.
Windows-/ Initiate input method editor (IME) reconversion.
Windows-J Swap foreground between the snapped and filled apps.


Posted by karthickreddyk with no comments

4.5 Framework Hosting - Model Binding Feature in .NET 4.5

 In ASP.NET 4.5, we can adopt an approach using which the Model can be directly bound with the DataBound controls and CRUD and pagination operations can be implemented very effectively. It incorporates concepts from the ObjectDataSource control and from model binding in ASP.NET MVC. We will see this shortly. ASP.NET 4.5 is based upon .NET 4.5 and it gets installed once you install Visual Studio 2011 preview.

Note: If you want to install Visual Studio 2011 preview, you can also use the Windows 8 Developer preview.

In this article I will be explaining a new ASP.NET 4.5 exciting feature called ‘Model Binding with Web Forms’. Up to previous versions, webforms for data-binding used to make use of the ‘Eval’ method. During runtime, calls to Eval makes use of reflection against the currently bound data object and reads value of the member with the given name in Eval method. (Read Why Eval is Evil). Once this value is read the result is displayed in HTML. Although this is easiest way of data-binding, it has limitations like checking the binding name during compilation time etc.

Update: Also check out the second part of this article ASP.NET 4.5: Filtering using Model Binding in ASP.NET Web Forms

In ASP.NET 4.5 the Model Binding has improved. We will be going through the complete model binding feature using the following steps:

- Model binding with Web Forms.
- Value Providers.
- Filtering.
- Performing Update Operations.

For this article I am using Sql Server 2008 R2 and a ‘Company’ database, with following Tables:

Department - DeptNo (int) Primary Key, Dname (varchar(50)),Location (varchar(50)).
Employee - EmpNo (int) Primary Key, EmpName (varchar(50)),Salary (int), DeptNo(int) Forwign Key.

Let’s get started.

Step 1: Open Visual Studio 2011 Developer Preview and create a new Web Application, make sure that the Framework version you select is .NET 4.5. Call this application ‘ASPNET45_ModelBinding’.

Step 2: In this project, add new folders and name them as Model and Department. In the Department folder, add two Web Forms (with master page). Name them as ‘Departments.aspx’ and ‘DepartmentDetails.aspx’.

Step 3: In the Model folder, add a new ADO.NET entity data model and name it as ‘CompanyEDMX.edmx’. In the Wizard, select Company Database and select Department and Employee table. After the completion of wizard, the below result will be displayed:

Step 4: Open the Departments.aspx in the ‘Source’ view and add the Repeater control in it with the Department model bound to it as below.

The above code shows some modified databound features for DataBound controls in ASP.NET 4.5. The Department Model is assigned to the ‘ModelType’ property of the repeater. This property is available to all DataBound controls. This allows us to define the type of data that is bound to the control and also allows to bind properties of the Model inside the control. The above code defines ‘ItemTemplate’ inside the repeater control which refers to the ‘DepartmentDetails.aspx’ by passing DeptNo value using QueryString to it.

Step 5: Go to the Departments.aspx.cs code behind, and write the following code:

The above code sets the datasource property for the repeater control.

Step 6: View the Departments.aspx inside the browser and the following result will be displayed: 
In your OS, observe the lower right corner of the System Tray. Instead of the ASP.NET Development server, ASP.NET 4.5 uses IIS Express as shown below: 

Step 7: In Step 4, we added the repeater control which has the ItemsTemplate and contains an <a href=””> to navigate to DepartmentDetails.aspx using a query string. This page is designed for displaying details of a particular Department. Open DepartmentDetails.aspx in the ‘Source’ view and add a DetailsView web UI databound control inside it. As explained Step 4, we need to assign the ModelType property of this control to ‘Department’ model.

All those who have used controls like DetailsView or FormView knows that these control are used for performing DML operations. Now to perform DML operations in earlier versions of ASP.NET i.e. from 2.0 to 4.0 we used to make use of ObjectDataProvider and this provider was usually configured using Get,Insert,Update and Delete methods form the source object. However the ASP.NET 4.5 DataBound controls e.g. GridView, FormView, DetailsView etc, exposes the following properties:

- SelectMethod: Used to make call to a method which returns IEnumarable.
- InsertMethod: Used to make call to a method which performs Insert operation.
- UpdateMethod: Used to make call to a method which performs Update operation.
- DeleteMethod: Used to make call to a method which performs Delete operation.

Configure the DepartmentDetails.aspx as shown below:

Step 8: Open the DepartmentDetails.aspx.cs and add the following code in it: 

Now carefully have a look at the above methods. None of these methods make use of any of the UI controls in the user interface. All these methods strictly work on Model objects and this feature drastically reduces additional coding. One more important fact is, if you observe the ‘GetDepartment()’ method, it has defined the ‘DeptNo’ input parameter with the QueryString Value provider. This automatically reads the DeptNo in the QueryString and displays the Department details inside the DetailsView.

Note: In previous versions of ASP.NET we could have done this using Request.QueryString[“DeptNo”]

Step 9: Now open Site.Master and add the following menu item:

<asp:MenuItem NavigateUrl="~/Department/Departments.aspx" Text="Departments"/>

Step 10: Make Default.aspx as a startup page and run the application. You will see the Default.aspx with Department and Employee menu. Once you click on ‘Department’ menu, Departments.aspx will be displayed. Now click on any Department and you will be transferred to ‘DepartmentDetails.aspx’ as below:

The QueryString has the DeptNo and based upon the value of the DeptNo, the DetailsView will display the  Department details. Here you can now test the Update and New (insert) functionality.

Check out the second part of this article ASP.NET 4.5: Filtering using Model Binding in ASP.NET Web Forms

Conclusion: The Model binding feature provides facility to the developers to develop Webforms which can be independent from the Model


What's New in .Net 4.5


Visual Studio Enhancements

Project Compatibility:-

This is the one feature that I liked a lot. If you have worked on a long running project which involved up gradation to a higher version then you have seen that once you open a project created in earlier version to a new version then it gets converted to new version via Visual studio conversion wizard. Problem with this approach was that a project once upgraded cannot be opened in earlier versions of visual studio. This created nuisance more so since sometimes it takes time to procure licenses for your entire time and we also wanted to save time by converting project at earliest to avoid any issues arising out of conversion. With VS 2011 developer preview Microsoft has done away with conversion wizard and improved compatibility.

Current Cursor line Code Highlighting:-

This is a cute little enhancement which actually saves a lot of time. While working on project many times you do a find which shows results in find window. On double clicking the result it takes you the line where it found the matches but many times I lost the cursor and then used down arrow key to track the movement and position of cursor. Now visual studio highlights line on cursor is placed currently.

Solution Explorer Enhancements

Solution explorer now combines Class view so that you can get more details about the class as you are working..

Quick Launch Box

This is another cool addition to visual studio menu bar which makes it easier to execute commands. As you can see the toolbar is much light weight now with only the commands that you use most often. Rest of the commands can be found by clicking the small dropdown button as shown below. Also see the highlighted Quick Launch(Ctrl+) box

You can see in image below as I type Form in Quick Launch it gives me plethora of options to choose from.

Posted by karthickreddyk with no comments
Filed under: