Dreamweaver 8.0.2
 
 

Dreamweaver & ASP.NET Code

 
   

In ASP we can put code wherever we want. We can make it as convoluted as we wish.

Try that in ASP.NET and you will generate errors.

 
 
ASP.NET Code Location

A: Shows pretty much what most of us do. We mix code and layout however we need to to make the page look right and to work. It can get disorganized.

B: Shows the ideal that ASP.NET designers had in mind. THe idea is one artistic team can build the look and feel and the serious geek's can write the code and it will all work. I suppose that may be possible. (I suppose this is what is meant by code behind.)

C: Shows an alternative that works also. If one uses just Visual Studio Net without much study this is pretty much what one would have. It is a good goal for those of us switching over to ASP.NET.

 
         
    The Problem  
   

My problem is that some of the things I want to do are pretty advanced. I've learned how to do those things with ASP. I am finding that some of those things just cannot be done in ASP.NET. Well, they can but figuring out how and finding the information in books, manuals, online help and tutorials is time consuming.

 
         
    What Dreamweaver Did  
     

The DW designers seem to have tried to get all their database handling code into a type B arrangement. But they went one step beyond what most of us would do.

It is possible to write all your code on a separate page and turn it into (compile) a DLL file and stash it in the BIN folder placed at the root of the site, which is why you see that thing about 'deploy' the support files. This is a smart thing to do and it speeds things up, on the server. DW helps you copy (deploy) DreamweaverCtrls.dll to the /bin folder. You can see what makes up that DLL as they provide the source code. Look in: C:\Program Files\Macromedia\Dreamweaver 8\Configuration\ServerBehaviors\Shared\ASP.Net\Scripts\Source

Lutz Roeder wrote a utility that will let you explorer the DLL and see the methods and properties.

See: http://regex.osherove.com/

 
     

Visual Studio .NET explains how to build these files and calls them CLASSES.

With the DLL and other files in DW they made many of their own tags and these hidden code pages handle those tags. Some like DropDownList and others are base tags handled by .NET framework (the software on the server). So, vanilla DW pages are mostly type B pages with DW putting their MM tags that access their code at the start of the 'B' type layout page.

 
         
    And if we want to get something done...  
     

Well... we could read the manuals and learn how ASP.NET is supposed be done... But ASP.NET has a pretty high learning curve. So, most of us will try to wing it. After all it still is ASP? Right?

Well, with a few of the main gotcha's handled you can sort of get away with that. That is what these pages are about.

DIM and other initialization statements typically go in a code block near the top of the pages code that looks like this.

<script runat="server">
  Sub Page_Load()
    'code here to run every time
    Dim rowCount AS INT = 0
    If NOT Page.IsPostBack Then
      'code here only runs on first page load
    else
      'code here runs only on POSTBACK page loads

    End If
  End Sub
</script>

I usually place my code after the DW tags (i.e., <MM:DataSet ) and in the <head> tag. By the way, the code above is an Event Handler. But, don't get the idea that all your ONLOAD code should go here. Remember which is server side and client side, this is the server side.

Also notice the DIM statement has changed. ASP.NET insists that you tell it what type of variable you are defining. That is called 'Strong Variable Typing.' It helps reduce future 'logic' problems in your code. Whatever, you have to do it. For most of us the types INT and STRING will do most of what we need. You can Google for the other VB (not script) Types to get a list.

You can still use ASP's <% %> in .NET but not always. If the <% %> code section is outside a runAt="server" block, expect problems.

You can get away with many <%= something %> just about anywhere. What you can do inside the .NET version of the tag is very restricted. Plan to use the new <%# %>, which is not equivalent but works in most places where you are not outputting to the page stream (writing to the page).

I'll show you how I got an <ASP:DropDownList /> populated from a data set and added a couple of non-database-item selections to the list on the next page.

 

 
       

 

©2005 Copyright Cates-Associates - Web Design by Dolphin Ad Design
ver 1.0
Uru Maps