Geeks With Blogs

The code samples in Microsoft All-In-One Code Framework are updated on 2010-12-13.

Download address:

Updated code sample index categorized by technologies: (it also allows you to download individual code samples instead of the entire All-In-One Code Framework sample package.)

If it’s the first time that you hear about Microsoft All-In-One Code Framework, please watch the introduction video on YouTube, or read the introduction on our homepage,  and this Port25 article


New ASP.NET Code Samples


Most of you have some experience in chatting with friends on the web. So you may want to know how to make a web chat application, it seems to be quite complicated. But ASP.NET gives you the power to buiild a chat room easily. In this code sample, we will construct our own web chat room with the amazing AJAX feature.

The principle is simple relatively. As we all know, a base chat application need 4 base controls: one List control to show the chat room members, one List control to show the message list, one TextBox control to input messages and one button to send message. User inputs his message in the textbox first and then presses Send button, it will send the message to the server. The message list will update every 2 seconds to get the newest message list in the chat room from the server.

We need to know, it is hard for us to make an AJAX web chat application like a windows form application because we cannot keep the connection after one web request ended. So a lot of events which communicates between client side and server side cannot be realized. The common workaround is to make web requests in every some seconds to check whether the server side has been updated. But another technique called COMET makes it possible. But it is different with AJAX and will not be talked in details in this KB. For more details about COMET, we can get some clues from the Reference.


CSASPNETCurrentOnlineUserList and VBASPNETCurrentOnlineUserList

This sample demos a system that needs to display a list of current online users' information. As a matter of fact, Membership.GetNumberOfUsersOnline Method  can get the number of online users and there is a convenient approach to check whether the user is online by using Membership.GetUser(string userName).IsOnline property,however many projects are not using membership.So in this case,the sample shows how to display a list of current online users' information without using membership provider.

It is not difficult to check whether the user is online by using session.Many projects tend to be used “Session_End” event to mark a user as “Offline”,however ,it may not be a good idea,because it can’t detect the user status accurately. In addition, "Session_End" event is only available in the "InProc" session mode. If you are storing session states in the State Server or SQL Server, "Session_End" event will never fire.
To handle this issue, we need to save the user online status to a  global DataTable or  DataBase. In the sample application, define a global DataTable to store the information of online users.Use XmlHttpRequest in the pages to update and check user's last active time at intervals and also retrieve information on how many users are still online. The sample project can auto delete offline users' information from a global DataTable by checking users’ last active time.

A step-by-step guide illustrating how to display a list of current online users' information without using membership provider:

1. Login page.

Let user sign in and add current user’s information to a global datatable while Initialize the global datatable which used to store information of current online users.

2. Current online user list page.

Use XmlHttpRequest in this page to update and check user's last active time at intervals and also retrieve information on how many users are still online.

3. If user closes the page without clicking  the sign out link button ,the sample project can auto mark the user as offline and delete offline users' information from a global DataTable which used to store information of current online users  by checking users’ last active time. Then the current online user list will be like this:



This sample demonstrates how to find the geographical location from an IP address. As we know, it is not hard for us to get the IP address of visitors via Request.ServerVariable property, but it is really difficult for us to know where they come from. To achieve this feature, the sample uses a free third party web service from, which returns the information about an IP address we send to the server in the format of XML, JSON or CSV. It makes all things easier.



Sometimes we do an operation which needs long time to complete. It will stop the response and the page is blank until the operation finished. In this case, we want the operation to run in the background, and in the page, we want to display the progress of the running operation. Therefore, the user can know the operation is running and can know the progress.


In windows forms TreeView, each tree node has a property called "Tag" which can be used to store a custom object. Many customers want to implement the same tag feature in ASP.NET TreeView. This project creates a custom TreeView control named "CustomTreeView" to achieve this goal.

CSASPNETRemoteUploadAndDownload and VBASPNETRemoteUploadAndDownload

This code sample was created in response to a code sample request in our new code sample request frunction for customers.

The code samples demonstrate uploading files to and downloading files from a remote HTTP or FTP server. In .NET Framework 2.0 and higher versions, there are some lightweight class libraries which support HTTP and FTP protocol transmission. By using these classes, we can achieve this programming requirement.


CSASPNETImageEditUpload and VBASPNETImageEditUpload

This demo will shows how to insert, edit and update a common image with the type of "jpg", "png", "gif" or "bmp" . We mainly use two different SqlDataSources with the same database to bind to GridView and FormView in order to establish the “cascading” effort. Besides we apply our self-made ImageHanlder to encoding or decoding images of different types, and use context to output the stream of images. We will explicitly assign the binary streams of images through the event of “FormView_ItemInserting” or “Form_ItemUpdating” to synchronize the stream both in what we can see on an aspx page as well as in what’s really stored in the database.


WebBrowser Control, Network and other Windows General New Code Samples


CSWebBrowserSuppressError and VBWebBrowserSuppressError

The sample demonstrates how to make WebBrowser suppress errors, such as script error, navigation error and so on.


CSWebBrowserWithProxy and VBWebBrowserWithProxy

The sample demonstrates how to make WebBrowser use a proxy server.


CSWebDownloadProgress and VBWebDownloadProgress

The sample demonstrates how to show progress during the download. It also supplies the features to Start, Pause, Resume and Cancel a download.


CppSetDesktopWallpaper, CSSetDesktopWallpaper and VBSetDesktopWallpaper

This code sample application allows you select an image, view a preview (resized smaller to fit if necessary), select a display style among Tile, Center, Stretch, Fit (Windows 7 and later) and Fill (Windows 7 and later), and set the image as the Desktop wallpaper.

CSWindowsServiceRecoveryProperty and VBWindowsServiceRecoveryProperty

CSWindowsServiceRecoveryProperty example demonstrates how to use ChangeServiceConfig2 to configure the service "Recovery" properties in C#. This example operates all the options you can see on the service "Recovery" tab, including setting the "Enable actions for stops with errors" option in Windows Vista and later operating systems. This example also include how to grant the shut down privilege to the process, so that we can configure a special option in the "Recovery" tab - "Restart Computer Options...".


New Office Development Code Samples


CSOneNoteRibbonAddIn and VBOneNoteRibbonAddIn

The code sample demonstrates a OneNote 2010 COM add-in that implements IDTExtensibility2. The add-in also supports customizing the Ribbon by implementing the IRibbonExtensibility interface. It is a skeleton OneNote add-in that developers can extend it to implement more functions. The code sample was requested by a customer in our code sample request service. We expect that this could help developers in the community.


New Windows Shell Code Samples


CppShellExtPreviewHandler, CSShellExtPreviewHandler and VBShellExtPreviewHandler

In the past two months, we released the code samples of Windows Context Menu Handler, Infotip Handler, and Thumbnail Handler. This is the fourth part of the shell extension series: Preview Handler.

The code samples demo the C++, C# and VB.NET implementation of a preview handler for a new file type registered with the .recipe extension. Preview handlers are called when an item is selected to show a lightweight, rich, read-only preview of the file's contents in the view's reading pane. This is done without launching the file's associated application. Windows Vista and later operating systems support preview handlers.

To be a valid preview handler, several interfaces must be implemented. This includes IPreviewHandler (shobjidl.h); IInitializeWithFile, IInitializeWithStream, or IInitializeWithItem (propsys.h); IObjectWithSite (ocidl.h); and IOleWindow (oleidl.h). There are also optional interfaces, such as IPreviewHandlerVisuals (shobjidl.h), that a preview handler can implement to provide extended support. Windows API Code Pack for Microsoft .NET Framework makes the implementation of these interfaces very easy in .NET.

The example preview handler provides previews for .recipe files. The .recipe file type is simply an XML file registered as a unique file name extension. It includes the title of the recipe, its author, difficulty, preparation time, cook time, nutrition information, comments, an embedded preview image, and so on. The preview handler extracts the title, comments, and the embedded image, and display them in a preview window.


In response to many customers' request, we added setup projects in every shell extension samples in this release. Those setup projects allow you to deploy the shell extensions to your end users' machines.


Download address:

Updated code sample index categorized by technologies: (it also allows you to download individual code samples instead of the entire All-In-One Code Framework sample package.)

If you have any feedback for us, please email: We look forward to your comments.

Posted on Wednesday, December 15, 2010 10:35 PM | Back to top

Comments on this post: December release of Microsoft All-In-One Code Framework is available now.

# re: December release of Microsoft All-In-One Code Framework is available now.
Requesting Gravatar...
Thank you for the tips. There is something written in Chinese. How can I change the language?
Left by professional writing help on Jul 13, 2011 6:43 PM

Your comment:
 (will show your gravatar)

Copyright © Geekswithblogs | Powered by: