ASP.Net Code Snippets for Visual Studio

When you need code for a specific job, then check out this list. Instead of scrounging around in your notes, I put some major code snippets here for you. In most cases they are copied from our ASP projects. The "Lesson Code" items are taken from our classroom projects & lectures.

  • Lesson Code
    Lesson 2: Formatting ASP Pages
  • Lesson Code
    Lesson 3: Learning ASP
Learning ASP....good starting point. Shows Streams, controls collections, client-side JavaScript, how to add a message box to a web form, adding html attributes in C#, redirection, Server.Mappath and more!

Default Page (handles customer data)
Streams Page (where they make a purchase)
  • Lesson Code
    Lesson 8: LINQ to SQL
  • LINQ to SQL samples, error fixes, etc.
  • Visual Basic &  C#


The ADO Model I showed you in Class
How to fill a datagrid with ADO Objects
How to sort the datagrid (Code)
How to sort the datagrid (Document)
How to edit the datagrid

How to update the datagrid records
How to add new records to the datagrid
How to create ADO Objects in code
Access Upsizing Wizard


  • ADO & SQL DB

The ADO Model I showed you in Class
How to create ADO SQL Objects in code
How to Use SQL Query Strings
How to call a SQL Stored Procedure
How to create an ADO-SQL CLass module
How to call/use my ADO-SQL Class
SQL string for related tables
SQL Where clause & wild card

ASP 2.0

How to add conn to Web.config using AttachDBFile

  • DataGridView

How to create template columns
How to sort the datagrid (Document)
How to hide a column in the datagrid

How to create GridView & Format at runtime
DataGridView Tips & Tricks


  • SQL & SQL Server

SQL Search strings
SQL Strings
SQL Server Authentication Modes
Configuring a Trusted SQL Server Connection
My Stored Procedure Class
Running Stored Procedures Using my SP Class (see above)


  • DataReader

How to use the DataReader to fill a grid              
How to use the DataReader to fill a list box
  • JavaScript & Browser

Client-Side Validation using JavaScript
How to close the browser or active window
How to set focus to a text box
How to add a message box to ASP page
  • Managing State

Session State
How to Use SQL Query Strings

  • Master Pages & Content Pages
How to add a Master Page to existing project or form
Clear textboxes on a content page
Clear textboxes on a regular web form
  • Web Services

How to use the Amazon. COM web service
How to use my Math Web service
My Simple Math Web Service
Web Services Video
  • Web Parts

How to change WebPart Manager display mode
Using Web Parts Training Video
  • XML


ASP.Net Support

HTML Resources

Internet Information Server


Database Resources


Return to Main Menu

Copyright 1999-2009 Ronald P. Kessler, Ph.D.
All rights reserved.