Re: Asp.net 2.0 and Dreamweaver
- From: "tshad" <tfs@xxxxxxxxxxxxxx>
- Date: Fri, 17 Feb 2006 21:53:09 -0800
"Darren Kopp" <darrenkopp@xxxxxxxxx> wrote in message
news:1140201563.223715.172880@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Well, technically you don't have to re-write the code. There are,I have heard that also.
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 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 codeI think what it does is exactly how I write my pages.
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.
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="style***"
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> </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>
</asp:DataGrid>
************************************************************************
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
Regards,
Darren Kopp
.
- References:
- Asp.net 2.0 and Dreamweaver
- From: tshad
- Re: Asp.net 2.0 and Dreamweaver
- From: Darren Kopp
- Re: Asp.net 2.0 and Dreamweaver
- From: tshad
- Re: Asp.net 2.0 and Dreamweaver
- From: Darren Kopp
- Re: Asp.net 2.0 and Dreamweaver
- From: tshad
- Re: Asp.net 2.0 and Dreamweaver
- From: Darren Kopp
- Asp.net 2.0 and Dreamweaver
- Prev by Date: RE: Custom control within repeater with custom object binding
- Next by Date: Close ModalDialog form after saving data
- Previous by thread: Re: Asp.net 2.0 and Dreamweaver
- Next by thread: The request failed with HTTP status 401: Unauthorized
- Index(es):