.NET Sample Code
-
Create Hashes - MD5, SHA1, SHA256, SHA384, SHA512
by David Cumps
In PHP its a simple task to generate hashes, but in C# it takes a little more work. We'll create a Hash class to simplify the process.
-
Encrypting Web.config sections in ASP.NET 2.0
by Xavier Larrea
Learn how to encrypt any section of your Web.config file on-the-fly and programatically; plain-text connection strings in your config file are no more!
-
Convert Decimal Integer Values to Binary String in VB6
by Alex Etchells
A small function to convert decimal integer values to a binary string. The number of bits can be optionally specified but this will be increased if insufficient.
-
How to write to an XML file
by Edward Tanguay
Writing to XML files is quite easy in ASP.NET as there are so many objects prepared for you -- you just need the syntax on how to use them. This code shows you how to write a simple member XML file.
-
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.
-
Random Numbers... That Work!
by Karl Moore
Has all this talk about seeds got you confused? Here's a nice snippet to show you the best way to get random numbers in .NET.
-
How to access a MySQL database with .NET
by Edward Tanguay
Demonstrates how to connect to a MySQL database with C#.
-
Double buffering in .NET
by Simon Soanes
Ever wondered how to double buffer with a Graphics object so your GDI+ based game/control doesn't flicker annoyingly? Here's how!
-
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.
-
Binding Multiple Fields to ASP.NET ListControl classes
by Neil Dodson
Out of the box, the ASP.NET list controls (CheckBoxList, RadioButtonList, DropDownList) only support data binding on a single field. Learn how to work around this to bind to as many fields as you need.
-
Embed text in Image using ASP.NET
by Julian Roberts
Demonstrates how to dynamically embed a text caption embedded into an image.
-
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!
-
XML Node Insert
by Paul Parks
Someone recently asked on the Undernet #C# channel for help with inserting a block of XML into an existing XML document. After perusing a couple of MSDN articles here's what I came up with.
-
Display SQL Server table data in a browser
by Edward Tanguay
Just supply your database connection string and this code will give you a radio button list of all your SQL Server tables and will show their fields.
-
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.
-
How to delete records with SqlCommand
by Edward Tanguay
This code shows you how to delete records with an SQL statement and get the number of records deleted returned back as an integer.
-
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).
-
Date And Time Validation Functions
by Hari K
This function is used for VB.Net developers. It is useful for Date validate when the date format is "dd/MM/yyyy" or "dd/MMM/yyyy". Time validation is also useful for Validating the given time in the format of "HH:mm:ss"
-
Execute a Process and Fetch its Output
by James Crowley
Demonstrates how to redirect the output of a shell program (such as a batch file) so you can fetch the text it returns.
-
I need a time-out!
by Wouter van Vugt
I need a time-out! Or more specifically, my methods need a time-out mechanism. And because I spent seven projects and quite some time on the web trying to find out how to do it correctly, I am writing this small article about the works.