Sample Code
-
Login Form
by Safreak
This code allows a user to login to another form if that user has a profile within a database. Since many newbies are often looking for login code, hopefully this simple Access example will be helpful.
-
Show/Hide Desktop Icons
by Adil Hussain Raza
This code uses API calls to Hide/Unhide icons on the desktop. This code uses FindWindowEx & ShowWindow API Calls to do the job.
-
Dynamically loading an IBindableTemplate
by James Crowley
Demonstrates how to dynamically load an IBindableTemplate from a file for use with new ASP.NET 2.0 controls such as the FormView, to workaround the lack of a LoadBindableTemplate method in the new version of the framework.
-
Binding a Control to an Enum
by James Crowley
Ever had an Enum (with a set of names and values) that you wanted to bind to a control like a DropDownList? Here's how.
-
Generate an Image of a Web Page
by Alan Dean
Demonstrates how to fetch images and thumbnails of web pages using a hidden web browser control.
-
Redirecting Without Halting Execution
by Lee Gunn - .NET C# Scotland
This snippet demonstrates how to send a redirect (302) to a client without halting execution.
-
A Simple ASP.NET MessageBox Class
by Lee Gunn - .NET C# Scotland
When moving from Windows Forms to ASP.NET Web Forms, an API that may be missed is that offered by the System.Windows.Forms.MessageBox Class. Here we implement it for ASP.NET!
-
Reading Binary Data in C#
by Jon Skeet
How to read binary data from a file in C# - the right way!
-
Using the Credential Management API
by Alan Dean
Following secure development best practice, an application should obtain and store user credentials securely. Microsoft has provided a means to accomplish this on the desktop: the unmanaged Credential Management API, which exposes the capability to provide a standard login experience for the user which is also secure. This code demonstrates how to create a generic dialog implementation using this API.
-
Parse a UK Date String
by James Crowley
Ever wondered why DateTime.Parse doesn't recognise non-US date format? Here's how to get it to!
-
Easy Asynchronous Programming
by Simon Soanes
A simple demonstration of how to use multithreading and delegates in .NET to execute a method that will take a long time, without locking up our main thread.
-
Dynamic thumbnail images from ASP.NET
by Brock Allen
This sample code is an IHttpHandler implementation that reads a JPG from the filesystem and dynamically generates a thumbnail sized version of the image and emits that to the response stream. What I like about this approach is that you don't need to create a file on the filesystem for the thumbnail as it's all done in memory.
-
Cross page postbacks in ASP.NET 2.0
by Brock Allen
ASP.NET 2.0 introduces the ability to have an ASPX page postback to a different ASPX page with cross page postbacks. This was done all the time in ASP but wasn’t supported in ASP.NET 1.x. Here we show you how to use this new feature.
-
Read MP3 Tag Information (ID3v1 and ID3v2)
by Erin Jones
This sample source code demonstrates how to read IP3v1 and IP3v2 tag information from MP3's, along with MPEG headers too.
-
Randomly Sorting Records
by James Crowley
Here's now to randomly sort records in SQL Server 2000 - so you can potentially select say 10 random items from a table.
-
Permanent 301 Redirect with QueryString in IIS
by James Crowley
If anyone's ever tried to move domain, you'll know its a pain. One way to make things a little easier is to provide an automatic 301 redirect from your old domain to your new one - this marks the new destination as a permanent change, and will generally be picked up by search engines. This shows you how to do this redirect with IIS, passing the full path and query strings along too.
-
Inserting images into Word documents using XML
by Jonathan Greensted
I've seen many, many requests on the Microsoft newsgroups asking how you can insert a picture into a Word document without saving it to the file system first. This example application described in this blog illustrates both methods for inserting a picture firstly using the Word object model (InlineShapes.AddPicture) and secondly using Word's XML support (InsertXML).
-
Windows Forms and the Idle Loop
by Mike Taulty
When you're writing Windows Forms applications it's always nice to be able to keep the UI responsive in order to avoid frustrating the user. Here's a method of completing your asynchronous work on the Application Idle loop rather than allowing another thread to wander into your Windows Forms code and then trying to deal with it by Control.Invoke.
-
Programatically Load User Controls
by Dave Wanta
How to programatically load user-controls from code behind pages and then access their properties using reflection.
-
Spoofing the Referrer using HttpWebRequest
by Dave Wanta
Here's a simple way to spoof the referrer to a web page during a web request.