Asp.net 2.0 and Dreamweaver

T

tshad

Can you use Dreamweaver and VS.Net together now?

I have a site that was built with DW code inside (therefore you could not
use VS.Net 2003 with it).

Is this still the case?

Apparently, you can use code inside with the new version version of VS, but
do you have to run the site as a total site or can you use both side by
side.

I would like to convert my site to asp 2.0 and use VS with it, but I don't
want to do that if there is going to be problem using VS with all the pages
I used DW to create.

Thanks,

Tom
 
D

Darren Kopp

Are you talking about the code as inline code rather than code in a
code behind? I use VS.Net 2003 with dreamweaver (dreamweaver for
design stuff), but I will always jump back to VS for adding controls to
the page and such (since it creates the stuff i need automatically in
the code behind).

Just go to a aspx file in the solution explorer, right click, open
with, then add the dreamweaver executable to the list (you can make it
default, but messes with code behind or resx, something).

If you could clarify what you mean by "DW code inside" that would help.

Regards,
Darren Kopp
http://blog.secudocs.com/
 
T

tshad

Darren Kopp said:
Are you talking about the code as inline code rather than code in a
code behind? I use VS.Net 2003 with dreamweaver (dreamweaver for
design stuff), but I will always jump back to VS for adding controls to
the page and such (since it creates the stuff i need automatically in
the code behind).

Just go to a aspx file in the solution explorer, right click, open
with, then add the dreamweaver executable to the list (you can make it
default, but messes with code behind or resx, something).

If you could clarify what you mean by "DW code inside" that would help.

When I talk about code-inside, I am talking about one page for both code and
design as opposed to code behind. This is also the direction MS is taking
in VS 2005. You now have 3 models, apparently.

In VS2003, you had to use Code behind, so that if you used a single page, it
wouldn't work in VS 2003.

I have a site with all my pages single .aspx pages. There are no .aspx.vb
(or aspx.cs).

Thanks,

Tom
 
D

Darren Kopp

Then click the "The ASP.NET 2.0 Coding Model" link... tried to put the
anchor, but it doesn't jump there automatically.

-Darren
 
T

tshad

Darren Kopp said:

This is good news.

But I believe their explanation is totally wrong.

I have had the debate (code-inside or Code-inline vs Code-Behind) with many
people in the past and still prefer the one page approach. Apparently, so
does MS since it is now the default model (according to this article). I
have even been told that PROFESSIONAL programmers use code behind, as if
there were no professional programmers before VS.

The error in the article is comparing asp.net code-inside(inline) with asp.
This is absolutely incorrect.

*************************************************************************************************
In ASP.NET 1.x, you could develop an ASP.NET page in one of two ways. First,
you could put your code directly inline with your ASP.NET tags. The code
inline model is very similar to the coding model that was prevalent with
classical ASP and other scripting languages. However, the code inline model
has several problems, such as the intermixing of code and HTML. ASP.NET 1.0
introduced the code-behind model as a replacement. The code-behind model
used an external class to house the code, while the ASPX page contained the
HTML and ASP.NET tags. The code-behind model thus successfully separated
code from content; however, it created some interesting inheritance issues
and forced the developer to keep track of two files for each Web page.

Although ASP.NET 2.0 still supports both of these models, several
significant changes have been made.
********************************************************************************************************

You don't mix the html code and scripting code as you do in asp. You have
complete separation as you do in the Code-Behind. The separation happens by
putting the Script at the top of the page and the HTML at the bottom. (or
you could reverse this, I suppose).

Code Inline
*******************************************************************************************************************
The code inline model is now the default model for Visual Studio 2005. Any
code you add to the page will automatically be added to a <script> block
within the ASPX file instead of to a code-behind class. However, Visual
Studio 2005 still displays the code in the code view. In other words, you
can keep using Visual Studio like you always have, except that code will be
placed directly in the ASPX page instead of a separate class.
******************************************************************************************************************

As they say here (and as I have always said), inline still keeps the
separation. But according to this, VS will create the Script block for
you - which is fine.

This always made more sense than that the 2 file method.

What I am curious about, is whether it will recognise old code not written
in VS and handle it correctly, or is there some hidden code somewhere that
MS uses to navigate the page and site.

I would like to just start using VS2005 on my current site and bring it up
to 2.0, without having to rewrite all my pages to work with the new models
set up by MS. It sounds like this is the case, unless there is some gotcha
that you won't find out about until you try it.

Thanks,

Tom
 
D

Darren Kopp

Well, technically you don't have to re-write the code. There are,
however, changes between 2.0 and 1.1, so you may have to rewrite some
code. I have not used the inline approach, i have used the code behind
model, so I am not sure if what i say next will apply. But I had some
1.1 code that i brought into a 2.0 project and tried to compile but
with errors because some of the coding techniques i used were now
obsolete, and the compiler recommended what to do instead.

So, the 1.1 to 2.0 conversion isn't guaranteed to not have any code
rewriting, but for non-obsolete code it should work fine with VS2005.
I know there is a conversion wizard that will help you convert all of
the existing code, but I believe that is for project based applications
with code-behind, but it may apply to inline files as well, I have not
tried.

Also, I think the part where it talks about the inserting of script
block and that is this: the code automatically goes into the script
block, but i believe there are 2 different views for looking at the
aspx source. One of them is HTML view which shows all of the html and
the script blocks, and then i think there is a code view, which shows
only the <script> blocks, but as i have not tried it i cannot guarantee
that's how it is.

As for the comparison to ASP, I think that is correct, depending on how
you set up your ASP page. Similar to the <script> blocks, a developer
could have just encapsulated all of the code between <% %> blocks at
the beginning of the page, and then called the sub routines and
functions throughout the page. This lead to "spaghetti code", but I
think in some aspects that still exists in .NET, even with a
code-behind model.

All in all i guess it all comes down to preference, and I guess that is
why Microsoft supports both methods, and I personally can see
advantages within each method (I admit, sometimes I get bothered having
to open the code-behind for the page).

Regards,
Darren Kopp
 
T

tshad

Darren Kopp said:
Well, technically you don't have to re-write the code. There are,
however, changes between 2.0 and 1.1, so you may have to rewrite some
code. I have not used the inline approach, i have used the code behind
model, so I am not sure if what i say next will apply. But I had some
1.1 code that i brought into a 2.0 project and tried to compile but
with errors because some of the coding techniques i used were now
obsolete, and the compiler recommended what to do instead.
I have heard that also.
I will have to do extensive testing before I attempt it.
So, the 1.1 to 2.0 conversion isn't guaranteed to not have any code
rewriting, but for non-obsolete code it should work fine with VS2005.
I know there is a conversion wizard that will help you convert all of
the existing code, but I believe that is for project based applications
with code-behind, but it may apply to inline files as well, I have not
tried.

Also, I think the part where it talks about the inserting of script
block and that is this: the code automatically goes into the script
block, but i believe there are 2 different views for looking at the
aspx source. One of them is HTML view which shows all of the html and
the script blocks, and then i think there is a code view, which shows
only the <script> blocks, but as i have not tried it i cannot guarantee
that's how it is.
I think what it does is exactly how I write my pages.

It knows where the script block is so it can logically separate the HTML
from the Script.

Here is how I write a Code inside page:
***************************************************************************
<%@ Page Language="VB" trace="false" debug="true" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="MyFunctions" %>
<script runat="server">
Sub Page_Load(s as Object, e as EventArgs)
if not IsPostBack then
call FillDrops()
end if
end sub

Sub FillDrops()
Dim myDbObject as new DbObject()
Dim DBReader As SqlDataReader

Dim parameters As SqlParameter () = { _
New SqlParameter("@Users",SqlDbType.BigInt) }

parameters(0).value = Session("User1")

dbReader = myDbObject.RunProcedure("GetCountries", parameters)
exit sub
Country.DataSource=dbReader
Country.DataTextField= "CountryName"
Country.DataValueField="CountryCode"
Country.databind()
Country.Items.Insert(0, "Select Country")
end Sub
</script>
<html>
<head>
<title>:: Staffing Workshop ::</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../../final-site/option2/css/staffing.css" rel="stylesheet"
type="text/css">

<style type="text/css">
<!--
body {
margin-top: 5px;
}
..style5 {font-size: 9px}
..style7 {
color: #FFFFFF;
font-weight: bold;
}
-->
</style>
</head>

<body id="myBody" runat="server">
<form runat="server">
<table width="851" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>_
<asp:DropDownList ID="Country" runat="server" /> </td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table>
</form>
</body>
</html>
****************************************************************************
*

Complete separation. I absolutely do not mix my script code with my HTML
code.
As for the comparison to ASP, I think that is correct, depending on how
you set up your ASP page. Similar to the <script> blocks, a developer
could have just encapsulated all of the code between <% %> blocks at
the beginning of the page, and then called the sub routines and
functions throughout the page. This lead to "spaghetti code", but I
think in some aspects that still exists in .NET, even with a
code-behind model.

Actually, the only place I use the <% %> is in datagrids or some place where
I need to get data from a database container such as when I Databind to a
datagrid and need to use a template column in place of a BoundColumn, which
I find much more flexible and easier to manipulate. But this would be the
same in the Code Behind model.

*************************************************************************
<asp:DataGrid
Visible=true
AllowSorting="false"
AutoGenerateColumns="false"
CellPadding="0"
CellSpacing="0"
ID="DataGrid1"
runat="server"
ShowFooter="false"
ShowHeader="true"
GridLines="Both"
Width="650px" style="border-collapse:separate">
<alternatingitemstyle BackColor="#FFFFFF"/>
<itemstyle BackColor="#E9E9E9" ForeColor="#0000FF"/>
<headerstyle CssClass="jay" BackColor="#000000" ForeColor="#FFFFFF"
Font-Bold="true" />
<pagerstyle BackColor="white" />
<columns>
<asp:TemplateColumn Visible="true" HeaderText="Name"
ItemStyle-Font-Bold="true"
ItemStyle-Width="125px" HeaderStyle-Width="125px"
ItemStyle-VerticalAlign="middle">
<itemtemplate>
<asp:LinkButton ID="FullName" Text='<%#
Container.DataItem("FullName")%>' OnClick="GetApplicantDetails_Click"
runat="server"/>
</itemtemplate>
</asp:TemplateColumn>
</columns>
All in all i guess it all comes down to preference, and I guess that is
why Microsoft supports both methods, and I personally can see
advantages within each method (I admit, sometimes I get bothered having
to open the code-behind for the page).

The interesting thing is that it is not just what MS supports, but is what
it now defaults to, apparently.

Thanks,

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top