Creating Dynamic Web Sites with .Net and Dreamweaver MX

Over the last two years Microsoft has been funneling billions into developing and promoting it's new technology: .Net.

In this article you will learn how to format Macromedia's Dreamweaver MX to work with .Net for your Microsoft Web Servers. By the end of this article you will be able to program a .Net web site.


ADO.Net

You can use almost any type of database. Of course, ADO.Net connects very easily to Microsoft Access and SQL Server. For this exercise I am going to use the Microsoft Access example database named North Wind. If you have Access then you will have a copy of North Wind.

The North Wind database is named northwind.mdb. For this exercise the database will be placed in a directory named "databases" off the C: drive. It is important to remember where you place your database so you can connect to it through ADO.

In Dreamweaver open Windows Database Panel. In the top left hand corner of the Panel is a "+" that you should select it. You will be given and option to connect to an OLE DB Connection or SQL Server Connection. Select the OLE DB Connection. The OLE DB Connection Window opens as shown in Figure H.

Figure H: OLE DB Connection Window

The OLE DB Connection Window allows you to write a string that connects Dreamweaver to a database.  You do need to give you new connection a name. The name you can use is "ConnNet", though any name can be used.

To connect to the Access database add the following connection string:

"Provider=Microsoft.Jet.OLEDB.4.0;

 Data Source=c:\database\northwind.mdb"

Select OK. Select Windows, Site. You will see that you now have all of the files needed to create a .Net database.

Database Driven Site

Most of the steps you have just followed only need to be completed for the set up of the site. Once you are up and running and everything is configured correctly then there are very few worries.

Now you can have fun building web pages. This is, after all, what we are all being paid for.

Creating database driven web pages with .Net in Dreamweaver MX is exactly the same as any other Dreamweaver Application environment.

A collection of data, called a dataset, will be the first step you need to take to bind content from the database to the page.

Open the Binding Panel. Select the "+" symbol and choose DataSet (Query). This opens the DataSet window as shown in Figure I.

Figure I: The DataSet Window

The DataSet window conveniently allows you to choose, through drop down menus, many of the options you need. First, name your DataSet. I have named mine DataSet DataSet1.

Select "ConnNet" from the Connections Drop down. This will then dynamically populate all of the tables in that connection. Select Products from the drop down and select OK.

A list of all of the fields in the Products table is now presented to you in the Binding Panel.

From the Binding Panel locate "Product-Name", click and drag it onto the stage. Want to see it in action? Press F12 to preview the page. Voila! You have created your first .Net page. Now that was not too painful, was it?

If you open the page you are working in to Code view you will see that everything you have done has been completed in just 21 lines of code. Now try and compare this to an ASP page. You will see a huge difference - much more code with the ASP page.

If you want to extend what you have done why not try to insert a repeat region? Select the bound name ProductName on the page. Select Repeat Region in the Insert Panel. The Repeat Region Window opens as shown in Figure J.

Figure J: Repeat Region Window

Select OK. All of the C# code is added to the page. Preview the page. You will now see a list of all of the products.  You now have the foundation created that enables you to build a .Net web site.

Matthew David

Matthew David has been developing Flash based applications for over 6 years (that makes him very old in this business!). Examples of his work can be found at his web site www.matthewdavid.ws, or you can email him directly at mdavid@email.com.

Matthew’s most recent publications include content for Flash 5 Magic, Inside Dreamweaver 4, Flash 5: Visual FX, Web Publishing Bible and The Dreamweaver Bible. You can also see him popping up in many online magazines, such as Sitepoint.com, Windowatch.com, UDzone.com and DevX.com.

Currently, Matthew is working on two books and writing articles for Element K Journal’s Macromedia Solutions magazine. He is a available as a freelance consultant to work on web based projects.

See All Postings From Matthew David >>

Comments

Now I'm confused.

November 21, 2002 by Owen Eastwick

I'm looking to make the transition from ASP/VBScript to ASP.net. Naturally I want to use the best possible variation and implement best practices from the outset. So which language should I choose VB.net or C#?

Here it states: C# is worth learning as it typically performs 10x faster than VB.Net.

However in this article: http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=185, it states:
What language is the "best" language choice? If you are a VB wizard, should you take the time to learn C# or continue to use VB.NET? Are C# ASP.NET pages "faster" than VB.NET ASP.NET pages? These are questions that you may find yourself asking, especially when you're just starting to delve into .NET. Fortunately the answer is simple: there is no "best" language. All .NET languages use, at their root, functionality from the set of classes provided by the .NET Framework. Therefore, everything you can do in VB.NET you can do in C#, and vice-a-versa. The only differences among languages is merely a syntactical one.

The two articles are completely contradictory - so which is right?

RE: Now I'm confused.

November 21, 2002 by George Petrov
Hi Owen, I have to agree with you as both C# and VB.NET code gets compiled to the CLI (Common Language Infrastructure) they generated almost identical CLI code. So they really run at the approx same speed. I think David had it a bit wrong in its article. In the past this was true for C++ and VB - but not anymore in .NET

RE: RE: Now I'm confused.

November 21, 2002 by Owen Eastwick

Thank you George, that's a relief, while I believe there are still many differences I imagine that moving to VB.net from ASP/VBScript is a slightly smaller step than from ASP/VBScipt to C#.net.

RE: RE: Thanks for the tut. My dreamweaverMX still is not working with .net

December 3, 2002 by Matthew David

Hazelnut,

I just saw your question. I want to make sure that I have the following informtion correct:

  • you are running windows 2000
  • you have installed .NET 1.0
  • you are running MDAC 2.6+
  • you have Dreamweaver configured to develop for ASP.NET

As with ASP the .NET world can be a huggling act. I just want to make sure that everything is correct.

Matt

See all 9 Comments

You must me logged in to write a comment.