ASP.NET Sample Code
-
How to get the current SessionID
by Edward Tanguay
Demonstrates how to retrieve the current SessionID for storing session data in a database
-
Adding controls to PlaceHolders dynamically
by Edward Tanguay
A simple example demonstrating how to dynamically add controls to a PlaceHolder control.
-
Programatically Load User Controls
by Dave Wanta
How to programatically load user-controls from code behind pages and then access their properties using reflection.
-
Generate PDFs using C# and the free iTextSharp library
by James Crowley
Learn how to use the free iTextSharp library to load a PDF form, populate some dynamic fields, and then save out a flat PDF file.
-
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!
-
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.
-
How to access a MySQL database with .NET
by Edward Tanguay
Demonstrates how to connect to a MySQL database with C#.
-
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.
-
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.
-
Url Rewriting with Regex for ASP.NET 2.0
by Xavier Larrea
A new feature in ASP.NET 2.0 is it's built-in url rewriting support. When i looked into this new feature I found that it lacked regular expressions support, which is really the point of an Url Mapper. So, this code demonstrates how to create a Url Rewriting Module with Regex support in ASP.NET.
-
How to get an array of all files in a directory
by Edward Tanguay
This simple code will give you an array containing all files in a directory.
-
Uploading Files Using ASP.NET
by Man from Mars
No need of third party components to upload your files. It is so easy to upload files in ASP.NET using just 3 lines of code.
-
Debug ASP.NET pages using Tracing
by Julian Roberts
Demonstrates a useful debugging technique taking advantage of traces in ASP.NET.
-
Building an 'AJAX' ProgressBar in Atlas
by Wilco Bauwer
Learn how to write a basic, client-side Atlas progress bar, and download the source code.
-
How to simulate a status bar in a Web application
by Edward Tanguay
If you have a process that takes over 20 seconds or so on a Web application, you may want to let the user know the status of the process. Edward shows you how.