Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Developer Tool for ASP & Efficient Coding


Message #1 by "David Yee" <david@r...> on Fri, 19 Oct 2001 13:03:06 +0800
Can the experience ASP programmer advice me which will be the better option

of do coding?



1. I have tried program like UltraDev and InterDev.



But i found them to be limited in capability compare to writing the code

manually. Whenever i need to have conditional statement or dynamic SQL

statement, i have to use the code editor.. In the end, constantly switching

from GUI tool to code editor making me more confuse.  What does the

experience ASP programmer use for writing ASP coding?





2. How can i write more efficient and easy to maintain coding?



I have learned from the forum that we should separate presentation layer and

business layer which is different from what is taught in the Beginning ASP

3.0

I try to keep more business logic and ASP scripting in a function and call

that function instead of having too much ASP coding with HTML. Is this the

correct manner? Please comment on my coding. Is it fine? Thank You.









<!--#include file="../../connect.asp" -->

<html>

<head>

<title>Add New Program Listing</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>



<body bgcolor="#FFFFFF" text="#000000">

<table width="400" border="0" cellspacing="0" align="left">

  <tr>

    <td>

      <div align="center"> </div>

      <div align="center"></div>

      <p align="center"><b><font color="#6699FF"><u><font color="#000000"

size="4">AirPower

        Travel Administrator Area <br>

        <br>

        </font></u></font></b></p>

    </td>

  </tr>

  <tr>

    <td>

      <p><font size="2" face="Georgia, Times New Roman, Times, serif"

color="#FF9999"><b><font color="#000000">Welcome

        to AirPowerTravel Administrator, your Web-based console for

configuring

        AirPowerTravel.com settings and resources. </font></b></font> </p>

    </td>

  </tr>

</table>

<p>&nbsp;</p>

<p>&nbsp;</p>

<BR>

<% Dim checkprogram

   Set checkprogram = Server.CreateObject("ADODB.Recordset")

   strsql = "SELECT ProgramName FROM UmrahProgramListing WHERE ProgramName 

'" & Request.Form("programname") & "'"

   checkprogram.Open strsql, objconn, 3, 3 ,1



   If Not checkprogram.EOF Then

      checkprogram.close

   Set checkprogram = nothing

      Response.Redirect "../adminumrah.asp?program=exist"

   Else

      Response.Write generateform()

   Set checkprogram = nothing

   End If %>

<p></p>









<%

'------------------------------------------------------------

'   Generate form for user to enter program information

'------------------------------------------------------------



   Function generateform()

       strform = "<form name=addprogram method=post

action=addnewprogaction.asp?purpose=add>" & _

              "<table width=400 border=1 cellspacing=0 cellpadding=0

bordercolor=#000000>" & _

                 "   <tr bgcolor=#CC9966>" & _

                 "      <td colspan=2>" & _

                 "         <div align=center>Program Information for " &

Request.Form("programname") & "</div>" & _

                 "         <input type=hidden name=programname value=""" &

Request.Form("programname") & """>" & _

                 "      </td>" & _

                 "   </tr>" & _

                 "   <tr>" & _

                 "      <th align=center>Day</th>" & _

                 "      <th align=center>Activity</th>" & _

                 "   </tr>"





        For i = 1 to CInt(Request.Form("days"))

           forinput = forinput + "<tr>" & _

                                               "   <td align=center>" & i &

"</td>" & _

                                               "   <td><textarea

name=programs rows=3 cols=38></textarea></td>" & _

                                           "</tr>"

        Next



        endofform = "<tr>" & _

                                 "   <td colspan=2 align=center><input

type=submit value=""Add Now""></td>" & _

                            "</tr>"

       generateform = strform + forinput + endofform



   End Function

%>



<% If Request.QueryString("purpose") = "add" Then

'-----------------------------------------------------------

' Adding program information into Table UmrahProgramListing

'-----------------------------------------------------------

   Dim addprogram

   Set addprogram = Server.CreateObject("ADODB.Recordset")

      strsql = "SELECT * FROM UmrahProgramListing"

   addprogram.Open strsql, objconn, 3, 3 , 1



   For i = 1 to Request.Form("programs").Count

         addprogram.AddNew

   addprogram("ProgramName") = Request.Form("programname")

   addprogram("Day")         = i

   addprogram("Activity")    = Request.Form("programs")(i)

   addprogram.Update

      Next

   Response.Redirect "../adminumrah.asp?program=added"

   End IF %>





</body>

</html>





Message #2 by "Ken Schaefer" <ken@a...> on Fri, 19 Oct 2001 16:15:50 +1000
I believe that most experienced ASP developers code by hand. Which program

you use is a matter of preference - some use InterDev, others UltraEdit,

others TextPad, some Homesite, and so on. Any good text editor will do.





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

: How can i write more efficient and easy to maintain coding?

:

: I have learned from the forum that we should separate presentation layer

and

: business layer which is different from what is taught in the Beginning ASP

: 3.0

: I try to keep more business logic and ASP scripting in a function and call

: that function instead of having too much ASP coding with HTML. Is this the

: correct manner? Please comment on my coding. Is it fine? Thank You.



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



That's a good start. Write your business logic in routines. Put the routines

into include files. Process your business logic in a separate part of your

page to the part where you handle output to the browser.



Later on you might want to look at using web classes, or COM components to

further separate presentation and business logic.



Cheers

Ken



Message #3 by "David Yee" <david@r...> on Fri, 19 Oct 2001 16:59:38 +0800
Ken,



Thank you for your advice.



Regards

David Yee



Message #4 by "Enzo Zaragoza" <enzaux@g...> on Fri, 19 Oct 2001 21:48:31 +0800
Hi, David!  I'm not that proficient in ASP but I use Gaspy 2.1b you can 

download it from download.com.  I use it interchangebly with Macromedia 

Dreamweaver.  In Dreamweaver its a little bit slower to edit and quite 

confusing because there are almost the same color for asp and html code. 

 But I do my design in Dreamweaver then I just do my ASP coding in Gaspy 

2.1b because it is much faster and less use of memory and what good 

about this is it has different colors for html and asp and sql :) It is 

cool!



Enzo

  ----- Original Message -----

  From: David Yee

  To: ASP Web HowTo

  Sent: Friday, October 19, 2001 1:03 PM

  Subject: [asp_web_howto] Developer Tool for ASP & Efficient Coding





  Can the experience ASP programmer advice me which will be the better 

option

  of do coding?



  1. I have tried program like UltraDev and InterDev.



  But i found them to be limited in capability compare to writing the 

code

  manually. Whenever i need to have conditional statement or dynamic SQL

  statement, i have to use the code editor.. In the end, constantly 

switching

  >from GUI tool to code editor making me more confuse.  What does the

  experience ASP programmer use for writing ASP coding?





  2. How can i write more efficient and easy to maintain coding?



  I have learned from the forum that we should separate presentation 

layer and

  business layer which is different from what is taught in the Beginning 

ASP

  3.0

  I try to keep more business logic and ASP scripting in a function and 

call

  that function instead of having too much ASP coding with HTML. Is this 

the

  correct manner? Please comment on my coding. Is it fine? Thank You.









  <!--#include file=3D"../../connect.asp" -->

  <html>

  <head>

  <title>Add New Program Listing</title>

  <meta http-equiv=3D"Content-Type" content=3D"text/html; 

charset=3Diso-8859-1">

  </head>



  <body bgcolor=3D"#FFFFFF" text=3D"#000000">

  <table width=3D"400" border=3D"0" cellspacing=3D"0" align=3D"left">

    <tr>

      <td>

        <div align=3D"center"> </div>

        <div align=3D"center"></div>

        <p align=3D"center"><b><font color=3D"#6699FF"><u><font 

color=3D"#000000"

  size=3D"4">AirPower

          Travel Administrator Area <br>

          <br>

          </font></u></font></b></p>

      </td>

    </tr>

    <tr>

      <td>

        <p><font size=3D"2" face=3D"Georgia, Times New Roman, Times, 

serif"

  color=3D"#FF9999"><b><font color=3D"#000000">Welcome

          to AirPowerTravel Administrator, your Web-based console for

  configuring

          AirPowerTravel.com settings and resources. </font></b></font> 

</p>

      </td>

    </tr>

  </table>

  <p>&nbsp;</p>

  <p>&nbsp;</p>

  <BR>

  <% Dim checkprogram

     Set checkprogram =3D Server.CreateObject("ADODB.Recordset")

     strsql =3D "SELECT ProgramName FROM UmrahProgramListing WHERE 

ProgramName =3D

  '" & Request.Form("programname") & "'"

     checkprogram.Open strsql, objconn, 3, 3 ,1



     If Not checkprogram.EOF Then

        checkprogram.close

     Set checkprogram =3D nothing

        Response.Redirect "../adminumrah.asp?program=3Dexist"

     Else

        Response.Write generateform()

     Set checkprogram =3D nothing

     End If %>

  <p></p>









  <%

  '------------------------------------------------------------

  '   Generate form for user to enter program information

  '------------------------------------------------------------



     Function generateform()

         strform =3D "<form name=3Daddprogram method=3Dpost

  action=3Daddnewprogaction.asp?purpose=3Dadd>" & _

                "<table width=3D400 border=3D1 cellspacing=3D0 

cellpadding=3D0

  bordercolor=3D#000000>" & _

                   "   <tr bgcolor=3D#CC9966>" & _

                   "      <td colspan=3D2>" & _

                   "         <div align=3Dcenter>Program Information for 

" &

  Request.Form("programname") & "</div>" & _

                   "         <input type=3Dhidden name=3Dprogramname 

value=3D""" &

  Request.Form("programname") & """>" & _

                   "      </td>" & _

                   "   </tr>" & _

                   "   <tr>" & _

                   "      <th align=3Dcenter>Day</th>" & _

                   "      <th align=3Dcenter>Activity</th>" & _

                   "   </tr>"





          For i =3D 1 to CInt(Request.Form("days"))

             forinput =3D forinput + "<tr>" & _

                                                 "   <td 

align=3Dcenter>" & i &

  "</td>" & _

                                                 "   <td><textarea

  name=3Dprograms rows=3D3 cols=3D38></textarea></td>" & _

                                             "</tr>"

          Next



          endofform =3D "<tr>" & _

                                   "   <td colspan=3D2 

align=3Dcenter><input

  type=3Dsubmit value=3D""Add Now""></td>" & _

                              "</tr>"

         generateform =3D strform + forinput + endofform



     End Function

  %>



  <% If Request.QueryString("purpose") =3D "add" Then

  '-----------------------------------------------------------

  ' Adding program information into Table UmrahProgramListing

  '-----------------------------------------------------------

     Dim addprogram

     Set addprogram =3D Server.CreateObject("ADODB.Recordset")

        strsql =3D "SELECT * FROM UmrahProgramListing"

     addprogram.Open strsql, objconn, 3, 3 , 1



     For i =3D 1 to Request.Form("programs").Count

           addprogram.AddNew

     addprogram("ProgramName") =3D Request.Form("programname")

     addprogram("Day")         =3D i

     addprogram("Activity")    =3D Request.Form("programs")(i)

     addprogram.Update

        Next

     Response.Redirect "../adminumrah.asp?program=3Dadded"

     End IF %>





  </body>

  </html>





  "&lt;tr&gt;" &amp;

  


  Return to Index