当前位置:站长之家学习教程网站编程.net编程学习教程 → 文章内容

ASP.NET入门经典-First Experience with ASP.NET in DWMX

减小字体 增大字体 作者:佚名  来源:不详  发布时间:2005-12-17 13:05:26
This tutorial details the steps of building a basic ASP.NET vb application with the new DreamWeaver MX from the perspective of an experienced UltraDev 4 user. In this example we will build a simple news content management application. This tutorial covers ASP.NET objects, controls, and ASP.NET security as well as the issues I encountered working with ASP.NET VB pages in DWMX

Getting Started

We will be creating ASP.NET data driven Master/Detail pages as well as insert, update, and delete pages records with ASP.NET. You will also learn how to build forms using the new ASP.NET server controls, how to implement ASP.NET client side field validation, and how to develop custom ASP.NET controls.

In addition to coverage of DWMX features Dot Net News shows how to implement ASP.NET folder level security on your content management pages and discusses how to authenticate global site users with the ASP.NET authentication service. The complete code of this tutorial is available as a download.



This tutorial assumes you are familiar with creating databases in MS Access, that you understand the underlying concepts of application development, and that you are familiar Dreamweaver UltraDev.

First we’ll need to set up our Access database.[*] The news content system database is simple. Two tables tbl_Admin and tbl_New are all we need. The image to the left shows all the necessary tables and fields. The field types are self explanatory.

Now that we have a database to work with, we need to create a new web project. Inside that folder we’ll create the folder database and save our newly created Access db to it. While we are here we need to create the folder admin, asp, controls, images, and bin. Bin is an important folder that we will cover later.

Start DreamWeaver MX and select the Site drop down > New Site. The first thing you’ll notice—unless you’ve already changed the settings—is a Front Page like wizard thingy pops up. Looking closer now you’ll see two tabs: Advanced, Basic. We’re feeling brave, so we select the Advanced tab. This will open the familiar UD style Site definition Window. Set up the site root folders as usual. When we get to the server models drop down, though, we select ASP.NET VB.

Let’s enter the DWMX design environment and look around. The database Bindings and Server Behaviors tabs are now under the “Applications” section tool palette of the DWMX style GUI. But you’ll notice that instead of just Bindings and Server Behaviors you now have a tab Databases and Components. We’ll begin with the database tab.





The database tab is where you will define the database connection for your ASP.NET application. In ASP.NET a global configuration file web.config holds the database connection and other settings in XML. No, don’t panic, you don’t have to write XML. DWMX will create the web.config file for you.

Select “OLE DB” or “SQL Server” Connection from the “Databases” tab drop down. The expanded ASP.Net connection interface will open. You’ll see several new features: a Build Button and Templates. Click templates and select the driver appropriate for your database. Name the connection datasource then click the templates button. Select JET 4.0 driver for Access 2000 from the templates list box and click “OK”. You will be returned to the original window. Fill in the blank template for your connection string.[†] DWMX writes the web.config file when you click “OK” and close the connections interface. The XML in the web.config contains your database connection and every new *.aspx page you create in the site will automatically be linked to your database with the Dreamweaver Controls tag as soon as you add a dataset or any other SB just as the Connections include is placed in asp files.





<@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly= "DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a, culture=neutral"%>


You may want to customize the stock MX web.config, however. One customization I highly recommend is:

<system.web><customErrors mode="Off" /></system.web>


If you work over a network, this code is necessary. This enables specific error messages to be output to a remote user. Without it you must run the page from the desktop of the server machine to get a detailed error report.


--------------------------------------------------------------------------------

[*] Unlike classic asp, ASP.NET is not easily ported to SQL Server by changing the connection string. Most behaviors including datasets will need to be reapplied.

[†] The web.config file requires the complete physical path to the database, i.e. d:\web\net news\database\data.mdb. The Server.Mappath method will not work in the XML file.



Front End


When you begin your asp.net Master/Detail page set you will find the Insert > Master/Detail menu item is grayed out. This means you will have to make these pages without UltraDev automating the process for you.



The Master Page

Open a new file. Select ASP.NET VB from the “Dynami

[1] [2] [3] [4]  下一页