Posts

ASP.NET Configurations: Retrieve Multiple Connection Strings From The Current Web Application's Web.config File

So you have to work with multiple connection strings that you want to use in the Web.config file and you want to use it in the code behind file.    Below are the steps to retrieve multiple connection strings in the web.config file programmatically. 1. Make sure you have connection strings in your Web.config file.  A connection string looks something like this. <connectionStrings> <add name="NorthwindConnectionString" connectionString="Data Source=(local); Initial Catalog=Northwind;Integrated Security=True" providerName="System.Data.SqlClient" /> <add name="AdventureWorksConnectionString" connectionString="Data Source=(local); Initial Catalog=AdventureWorks;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings> 2. Now in the Default.aspx.cs file type in the following in the top of the file, where all the using statements are to use the System.Web.Co...

ASP.NET Configurations: Retrieve Connection String Programmatically

So you have a connection string that you want to use in the Web.config file and you want to use in the code behind file.  You can do that with a single line of code in your .cs file.  Below are the steps to retrieve a connection string in the web.config file programmatically. 1. Make sure you have a connection string in your Web.config file.  A connection string looks something like this. <connectionStrings> <add name="NorthwindConnectionString" connectionString="Data Source=(local); Initial Catalog=Northwind;Integrated Security=True" providerName="System.Data.SqlClient"/> </connectionStrings> 2. Now in the Default.aspx.cs file type in the following in the top of the file, where all the using statements are to use the System.Web.Configuration namespace using System.Web.Configuration; Obviously you can use it in any .cs file, the Default.aspx.cs is just an example. 3. In the Page_Load method type in the following line string co...

ADO.NET: SqlDataSource Control

Image
The SqlDataSource control provides you with a quick and easy way to access database data.  Most of the time you don't even have to write a single line of code.  Now this can a be a good thing and a bad thing, depends on how you look at things.  Most of the configuration and querying is performed via a configuration wizard. Here are the steps to creating a SqlDataSource: 1. In a ASP.NET project/web site drag a SqlDataSource control in under "Data" in the "Toolbox" tab into a .aspx page.   After you dragged the control it should look like this on your .aspx page 2. Click on "SqlDataSource1" control, then click on the ">" sign, a slide out menu appears.  Select "Configure Data Source". The "Configure Data Source" wizard will pop up. 3. Click on the "New Connection" button, the "Add Connection" wizard will pop up. Select or type in your "Server name".  If you have a local instance of SQL Server...

HTML5 Page Template

A little bit fancier, you want to specify the language and character set: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title></title> </head> <body> </body> </html> This is the bare minimum you need to write a HTML5 page: <!DOCTYPE html> <html> <head> <title></title> </head> <body> </body> </html>

HTML5 Tags

Image
Not Supported in HTML5: <tt> <strike> <noframes> <frame> <frameset> <dir> <center> <big> <basefont> <applet> <acronym> DOCTYPE tag: HTML5: <!DOCTYPE html> HTML 4: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> XHTML Strict: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> XHTML Traditional: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> New HTML5 Tags: Layout: Top area of the page: <header> Bottom area of the page: <footer> Navigation links: <nav> Line breaks: <wbr> UI: Progress bar, shows defined progress with flashing light: <progress> Show result of a calculation: <output> Meter (like a progress bar) but no flashing light: ...

Entity Framework Part 1: Generate an Entity Framework for the Northwind Database Tables

Image
In my previous post we've created the Northwind products page using the SqlDataSource data control, even though there's nothing wrong with the solution.  SqlDataSource is a an old technology and is not meant to be an enterprise solution.  SqlDataSource is the stone age of .NET data access technology.  The future of .NET is the Entity Framework. The goal of the Entity Framework is to create a conceptual model of your data store so that you can work with tables and rows as objects, or entities.  In essence the developer does not know or care what the data store is, he does not have to be a dba to work with the data. To demonstrate the Entity Framework let's create the Northwind products page using the Entity Data Model of the Northwind database. Here are the steps: 1. Open the Northwind project you created with the SqlDataSource 2. Righ-click on the Northwind project in "Solution Explorer", then select "Add", then "New Item" 3. Select "Data...

ASP.NET: Installing IIS 7

Image
You can use Visual Studio for all of your web server needs for local development, but it's essential that you familiar yourself with a full blown IIS version.  In this tutorial I will show how to install IIS on a Windows 7 machine. 1. Open the "Control Panel" 2. Select "Programs and Features"   3.  Click on "Turn Windows features on or off" 4.  In the "Windows Features" dialog box, select "Internet Information Services" option, then click "OK" 5. To manage the IIS instance on the machine type "mmc" into the start menu then press "Enter", the click "Yes" this will bring up the "Microsoft Management Console" 6. Click on "File" then "Add/Remove Snap in" or Ctrl+M 7. Select "Internet Information Services (IIS) Manager" snap-in in the "Available snap-ins:" dialog box 8. Click "Add", then click "OK" 9. Click on the "Internet ...