Upgrading from ASP to ASP.NET


ASP.NET provides several benefits over ASP in state management, security, performance, scalability, output cache control, Web farm support, configuration, deployment, and XML Web service infrastructure. The use of the built-in objects of ASP, such as Application, Request, Response, Server, and Session, are the same in ASP.NET. These objects are defined in classes that the System.Web namespace provides.

Some structural differences exist between ASP and ASP.NET. The page layout and coding style may differ. ASP.NET also has different ways to manage programming languages, code blocks, and page directives.

You can migrate an ASP Web application to ASP.NET using the Migration Assistant tool. After converting the code, you need to optimize and fix the errors that arise due to incompatibilities in the migration process.

Important

After converting the ASP application to an ASP.NET application, you can separate the business logic from the presentation logic and incorporate the server-side functionality by writing code-behind .vb or .cs files.

Creating an ASP Application

Consider an application, Complaint Monitoring System, that allows the registration and monitoring of customer complaints for faulty machine parts and peripherals. An end user can log on to the application, register a complaint, and view the status of the complaint using the complaint number that the application provides. The administrator can log on to the application, view complaints, change the passwords of application users, enter remarks against each complaint, and update the status of the complaint.

The conn.asp file creates the connection object to establish a connection with the Complaint database. Listing 3-9 shows how to create the conn.asp file:

Listing 3-9: Creating the Conn.asp File

start example
 <% set conn=Server.CreateObject("ADODB.Connection") conn.Open"Provider=SQLOLEDB.1; Persist Security Info=False; User ID=newlogin; password=password; Initial Catalog=Complaint;Data Source=SHOBHIT" %> 
end example

In the above listing, the conn.asp file creates the conn connection object and establishes a connection with the Complaint SQL Server database using the SQLOLEDB provider. You need to include the conn.asp file in each .asp file of this application to access the database because this file provides the connection object.

The login.html file provides the Login page that allows the end user to specify and submit login credentials. The Login page also provides a link to the end user to check the status of their complaints. Listing 3-10 shows how to create the login.html file:

Listing 3-10: Creating the Login.html File

start example
 <html> <head> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>COMPLAINT MONITORING SYSTEM</title> </head> <body bgcolor="#D1E7FA" style="text-align: Center" bgproperties="fixed"> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </p> <form method="post" action="./loginhandle.asp" style="text-align: Center"> <p style="line-height: 100%" align="center"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><font face="Verdana" size="5"> </font><font face="Verdana" size="6"><font color="#000080">COMPLAINT MONITORING SYSTEM</font>&nbsp;</font></b> </p> <hr size="6" color="#808080"> <br> <marquee bgcolor="#000080" width="83%" height="8%" style="font-family: Verdana; font-size: 18pt; font-weight: bold; text-align: Center; color: #FFFFFF" align="middle">Welcome to Complaint Monitoring System</marquee> <p style="line-height: 100%; text-indent: 0; margin-bottom: -4">&nbsp;</p> <div align="center"> <center> <table border="2" width="61%" height="1" bordercolordark="#000080" bordercolorlight="#000000" bgcolor="#CCCCCC" bordercolor="#000080" style="border-style: outset"> <tr> <td width="100%" height="1"> <p style="line-height: 90%; margin-bottom: -4">&nbsp; <p style="line-height: 90%; margin-bottom: -4"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <label for="fp1"><font face="Verdana"><b>Enter your Login Id :</b> </font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </label><input type="text" name="txtlogin" size="20" ></p> <p style="line-height: 90%; margin-bottom: -4"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; <label for="fp2"><font face="Verdana"><b>Enter Password :&nbsp;&nbsp;&nbsp; </b></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </label><input type="password" name="txtpassword" size="20" ></p> <p style="line-height: 90%; margin-bottom: -4"><br>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<input type="submit" value="Submit" name="submit" > &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; <input type="reset" value="Cancel" name="cancel"></p> <p style="line-height: 90%; margin-bottom: -4">&nbsp;</td> </tr> </table> </center> </div> <p>&nbsp; </p> <p>&nbsp; </p> <p align="left"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;< a href="./checkstat.asp"><font face="Verdana">Check status of your complaint</Font></a> </p> </form> </body> </html> 
end example

In the above listing, the Login page allows the end user to specify and submit login credentials. This page redirects the end user to the loginhandle.asp file using the post method when the end user clicks Submit.

The loginhandle.asp file verifies the login credentials of the end user and redirects the end user to the admin.asp file if the end user is an administrator; otherwise, it redirects the end user to the complaint.asp file. Listing 3-11 shows how to create the loginhandle.asp file:

Listing 3-11: Creating the loginhandle.asp File

start example
 <%response.buffer=true%> <!--#include virtual="adovbs.inc"--> <!--#include file="conn.asp"--> <html> <head> <script language="javascript"> function callback() {    window.history.back() } function callhome() {    window.location.replace("./login.html") } </script> <title></title> </head> <body bgcolor="#666666"> <% dim rs, username,password,passtest set rs=Server.CreateObject("ADODB.Recordset") username=request.form("txtlogin") password=request.form("txtpassword") mysql="select Password from Users where UserId='" & username & "'" rs.Open mysql, conn if username="administrator" and password=rs("Password") then Session("Logintest")=request.form("txtlogin") Session("Passwordtest")=request.form("txtpassword") response.redirect("./admin.asp") elseif username<>"administrator" and password=rs("Password") then Session("Logintest")=request.form("txtlogin") Session("Passwordtest")=request.form("txtpassword") response.redirect("./complaint.asp") else Session("Logintest")="" Session("Passwordtest")="" response.write("<h2><center> <font color='#FFFFFF'><br><br><br><br><br>Invalid Username or Password</font> </center></h2>") response.write("<h2><center> <font color='#FFFFFF'>Please try again!!!</font > </center></h2>")%> <center> <img border="0" src="/books/2/923/1/html/2/./back.gif" OnClick=callback()> <img border="0" src="/books/2/923/1/html/2/./home.gif" OnClick=callhome()> </center> <% end if %> </body> </html> 
end example

In the above listing, the loginhandle.asp page verifies the login credentials of the end user against the entries mentioned in the program. The program uses the response.redirect() method to direct the end user to the correct page.

The complaint.asp file provides the Enter Complaints page that allows the end user to enter complaint information, such as machine code, peripheral code, complainant name, the problem associated with the computer, location ID, and department code. This page verifies the specified information and redirects the end user to the comphandle.asp file when the end user clicks Submit. Listing 3-12 shows how to create the complaint.asp file:

Listing 3-12: Creating the complaint.asp File

start example
 <% response.buffer=true %> <!--#include virtual="adovbs.inc"--> <!--#include file="conn.asp"--> <%  dim rs,maccode,macdesc,sql set mrs=Server.CreateObject("ADODB.Recordset") set prs=Server.CreateObject("ADODB.Recordset") set lrs=Server.CreateObject("ADODB.Recordset") set drs=Server.CreateObject("ADODB.Recordset") mrs.Open "select * from Machine",conn prs.Open "select * from Peripheral",conn lrs.Open "select * from Location",conn drs.Open "select * from Department",conn %> <html> <head> <script language="javascript"> function callhome() {    window.location.replace("./login.html") } //This function validates the data on the form function validate(form1) {    var result=name()    var result1=problem()    if ((form1.txtmaccode.value=="") && (form1.txtpercode.value==""))    {       alert("Please enter the code of machine or peripheral that is not working")    }    else if(result==false)    {       alert("Please enter your name")       document.forms[0].txtname.focus    }    else if(result1==false)    {       alert("Please enter your problem")       document.forms[0].txtothers.focus    }    else    {       form1.submit()    } } function name() {    if (document.forms[0].txtname.value=="")    {       return false    }    else {       return true } } function problem() {    if (document.forms[0].txtothers.value=="")    {       return false    }    else    {       return true    } } function txtmaccode_onBlur(form1,mac) {   status=0   j=form1.txtmaccode.value   if(j=="")   {       status=1   }   for (i=0;i<form1.length;i+=2)   {       if (form1.elements[i].type == "hidden")       {          if(form1.elements[i].name==j)          {             form1.txtdesc.value=form1.elements[i].value form1.txtAMC.value=form1.elements[i+1].value             status=1             break            }       }    }     if(status==0)    {        alert("No such Machine exists!!!")       mac.value=""       mac.focus()    } } function callback() {    window.history.back() } function txtpercode_onBlur(form1,per) {    status=0    j=form1.txtpercode.value    if(j=="")    {        status=1    }    for (i=0;i<form1.length;i+=2)    {       if (form1.elements[i].type == "hidden")       {          if(form1.elements[i].name==j)          {form1.txtperdesc.value=form1.elements[i].value          if(form1.txtmaccode.value=="")          {             form1.txtAMC.value=form1.elements[i+1].value          }          status=1          break         }    } }  if(status==0) {     alert("No such Peripheral exists!!!")    per.value=""    per.focus() } }   </script> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>Enter Complaints</title> </head> <body background="./Acexpdtn.gif" bgproperties="fixed"> <form name="machine_form" method="POST" action="./comphandle.asp"> <% while not mrs.EOF     Response.Write "<input type='hidden' name='" & mrs("MachineId") & "' value='" & mrs("MacConfig") & "'>" Response.Write "<input type='hidden' name='" & mrs("MachineId") & "_2' value='" & mrs("AMCVendorId") & "'>" mrs.MoveNext wend %> <% while not prs.EOF Response.Write "<input type='hidden' name='" &   prs("PeripheralId") & "' value='" & prs("PerDesc") & "'>" Response.Write "<input type='hidden' name='" & prs("PeripheralId") & "_2' value='" & prs("AMCVendorId") & "'>" prs.MoveNext wend %> <input type="hidden" name="txtAMC" value=""> <p align="center">&nbsp;&nbsp;&nbsp; <font color="#000080">&nbsp;&nbsp; </font><font size="5"><font color="#000080" face="verdana">&nbsp;&nbsp;&nbsp;&nbsp; <b>COMPLAINT&nbsp; FORM</b> </font> </font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; </p> <hr noshade size="4" width="80%"> <p align="left"><label for="fp1" ><font face="verdana">&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; <b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Machine Code</font> </b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </label><input type="text" name="txtmaccode" size="23"  onBlur=txtmaccode_onBlur(machine_form,txtmaccode)></p> <p align="left"><label for="fp7" ><b><font face="verdana">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Peripheral Code</font></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </label><input type="text" name="txtpercode" size="23" onBlur=txtpercode_onBlur(machine_form,txtpercode)></p> <p align="left"><b><label for="fp10"><font face="verdana">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Machine Description&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> </label><input type="text" name="txtdesc" size="23"  readonly></b></p> <p align="left"><b>&nbsp;&nbsp;&nbsp;&nbsp;<label for="fp11"> <font face="verdana">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Peripheral Description&nbsp;&nbsp;</font></label><input type="text" name="txtperdesc" size="23"  readonly></b></p> <p align="left"><label for="fp6"><b><font face="verdana">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp; </font></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp; </label><input type="text" name="txtname" size="23"></p> <p align="left"><label for="fp5"><b><font face="verdana">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Location&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; </label><select size="1" name="cmbloc" style ="width:165px" readonly> <% while not lrs.eof response.write("<option>" & lrs("LocationName") & "</option>") lrs.movenext() wend %> &nbsp; </select></p> <p align="left"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<label for="fp9"><font face="verdana">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Department Code&nbsp;&nbsp;</font></label></b><label for="fp9">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp; </label><select size="1" width="20" style ="width:165px" name="cmbdept" > <% while not drs.eof response.write("<option>" & drs("DepartmentCode") & "</option>") drs.movenext() wend %> &nbsp; </select></p> <p align="left"><b>&nbsp;</b><b><font face="verdana">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Problem &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</font></b><textarea rows="2" name="txtothers" cols="32" ></textarea><b>&nbsp;</b><b>&nbsp;</b><b> &nbsp;</b></p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; <input type="button" value=" Submit " name="sub" OnClick=validate(machine_form) > <input type="reset" value=" Cancel " name="cancel">&nbsp; <input type="button" value=" Back  " name="back" OnClick=callback()> <input type="button" value="  Home  " name="home" OnClick=callhome()> </p> <p>&nbsp;</p> <p>&nbsp;</p> </form> </body> </html> 
end example

The above listing defines the following methods written in JavaScript:

  • callhome(): Loads the login.html page, which is the home page of the application.

  • validate(): Validates the data on the form.

  • name(): Checks whether the complainant name is blank or not. Returns true if the field is not blank and returns false if the field is blank.

  • problem(): Checks whether the problem field is blank or not. Returns true if the field is not blank and returns false if the field is blank.

  • txtmaccode_onBlur(): Executes when the focus exits the txtmaccode text box. This method retrieves the machine description for the specified machine code.

  • callback(): Displays the previous page in the browser.

  • txtpercode_onBlur(): Executes when the focus exits the txtpercode text box. This method retrieves the peripheral description of the specified peripheral code.

The above listing also shows the server-side script to retrieve location ID, department code, machine description, and peripheral description from the database. When the end user clicks Submit, the code redirects the end user to the comphandle.asp file.

The comphandle.asp file generates a complaint reference number based on the complaint information that the end user specifies. The end user uses the complaint reference number to check the status of the complaint. Listing 3-13 shows how to create the comphandle.asp file:

Listing 3-13: Creating the comphandle.asp File

start example
 <%response.buffer=true%> <!--#include virtual="adovbs.inc"--> <!--#include file="conn.asp"--> <html> <head> <script language=javascript> function callback() {    window.history.back() } function callhome() {    window.location.replace("./login.html") } </script> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>Generate Complaint Reference Number</title> </head> <body> <%  dim rs, maccode, deptcode, compltname, locid, amcvendorid, others, complaintid, peripheralcode, doc, dor, downtime, dd, mm, yy, h, min, sec maccode=trim(request.form("txtmaccode")) peripheralcode=trim(request.form("txtpercode")) deptcode=request.form("cmbdept") compltname=ucase(request.form("txtname")) locid=request.form("cmbloc") others=ucase(request.form("txtothers")) amcvendorid=request.form("txtAMC") dd=day(now()) mm=month(now()) yy=right(year(now()),2) h=hour(now()) min=minute(now()) sec=second(now()) doc=month(now()) & "/" & day(now()) & "/" & year(now()) if maccode<>"" then complaintid=maccode & mm & dd & yy & h & min & sec else complaintid=peripheralcode & mm & dd & yy & h & min & sec end if sql="insert into Complaint(ComplaintId,MachineId, Peripheralid, DepartmentId, DOC, DOR, Others, CompltName, LocationId, AMCVendorId, Status) values(' " & complaintid & " ',' " & maccode & " ',' " & peripheralcode & " ',' " & deptcode & " ',' " & doc & " ',NULL,' " & others & " ',' " & compltname & " ',' " & locid & " ',' " & amcvendorid & " ',0)" conn.Execute sql response.write("<h2><center> <font color='#0000FF'><br><br><br><br><br>Your complaint has been registered and your</font></center></h2>") response.write("<h2><center> <font color='#0000FF'>complaint number is " & complaintid & "</font></center></h2>") response.write("<h2><center> <font color='#0000FF'>Please note your Complaint No. for future reference.</font></center></h2>") %> <center> <img border="0" src="/books/2/923/1/html/2/./backblue.gif" OnClick=callback()> <img border="0" src="/books/2/923/1/html/2/./homeblue.gif" OnClick=callhome()> </center> </body> </html> 
end example

The above listing defines the callhome() and callback() JavaScript methods.

The above listing also defines server-side code to insert complaint information into the database and generate a complaint reference number.

The checkstat.asp file provides the Check Complaint Status page that enables the end user to specify the complaint reference number and request to view the complaint status. This page redirects the end user to the checkstathandle.asp file when the end user clicks Submit. Listing 3-14 shows how to create the checkstat.asp file:

Listing 3-14: Creating the checkstat.asp File

start example
 <%response.buffer=true%> <!--#include virtual="adovbs.inc"--> <!--#include file="conn.asp"--> <html> <head>    <script language="javascript"> function callback() {    window.history.back() }  function callhome() {    window.location.replace("./login.html") } </script> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type"   content="text/html; charset=windows-1252"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>Check Complaint Status</title> </head> <body bgcolor="#99CCFF"> <form name="checkstat" method="POST" action="./checkstathandle.asp"> <p>&nbsp;</p> <p><b><font size="6" color="#FF0000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;</font><font size="6" color="#000080">&nbsp;</font><font size="5" color="#000080" face="verdana"> Check status of your complaint</font></b></p> <p>&nbsp;</p> <p><b><font size="4"><font color="#FF0000" face="verdana">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font size="4" color="#000080" face="verdana">&nbsp;&nbsp; Enter your complaint no.</font><font color="#FF0000" face="verdana">&nbsp;</font>&nbsp;&nbsp; <input type="text" name="txtcomplaintid" size="20"></font></b></p> <p>&nbsp;</p> <p> <center> <input type="submit" value=" Submit "    name="submit"> <input type="reset" value="Cancel" name="cancel">&nbsp; <input type="button" value="   Back  " name="back" onclick=callback()> <input type="button" value="  Home  " name="home" onclick=callhome()></center> </p> <p>&nbsp;</p> </form> </body> </html> 
end example

The above listing defines the callhome() and callback() JavaScript methods.

The checkstathandle.asp file provides the Complaint Status page that shows the status of the complaint and the remarks entered by the administrator about the complaint. Listing 3-15 shows how to create the checkstathandle.asp file:

Listing 3-15: Creating the checkstathandle.asp File

start example
 <%response.buffer=true%> <!--#include virtual="adovbs.inc"--> <!--#include file="conn.asp"--> <html> <head> <script language="javascript"> function callback() {    window.history.back() } function callhome() {    window.location.replace("./login.html") } </script> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>Complaint Status</title> </head> <body> <% dim rs,complaintId set rs=Server.CreateObject("ADODB.Recordset") rs.CursorLocation=adUseClient complaintId=trim(request.form("txtcomplaintId")) sql="select Status,Remarks from Complaint where ComplaintId=' " & complaintId & " ' " rs.Open sql,conn,adOpenDynamic,adLockOptimistic if rs.RecordCount <=0 then Response.Write("<h2><center><font color='#FF6600' face='verdana'><br><br><br><br><br>No such complaint number exists.</font></center></h2>") %> <center> <img border="0" src="/books/2/923/1/html/2/./back.gif" OnClick=callback()> <img border="0" src="/books/2/923/1/html/2/./home.gif" OnClick=callhome()> </center>                   <%  else if rs("Status")=true then Response.Write("<h2><center><font color='#FF6600' face='verdana'><br><br><br><br><br>Your problem has been solved.</font></center></h2>") %> <center> <h3><font color="#FF6600" face="verdana">Remarks from the administrator :</font><br><br> <textarea  name="txtremarks" rows='2' cols='40' align="left" readonly> <%= rs("Remarks")%></textarea></h3> <img border="0" src="/books/2/923/1/html/2/./back.gif" OnClick=callback()> <img border="0" src="/books/2/923/1/html/2/./home.gif" OnClick=callhome()> </center> <% else Response.Write("<h2><center><font color='#FF6600' face='verdana'><br><br><br><br><br>Your problem has not been solved as yet.</font></center></h2>")                     %> <center> <h3><font color="#FF6600" face="verdana">Remarks from the administrator :</font><br><br> <b><textarea  name="txtremarks" rows='2' cols='40' align="left" readonly> <%= rs("Remarks")%></textarea></b></h3> <img border="0" src="/books/2/923/1/html/2/./back.gif" OnClick=callback()> <img border="0" src="/books/2/923/1/html/2/./home.gif" OnClick=callhome()> </center>                  <%  end if end if %> </body> </html> 
end example

The above listing defines the callhome() and callback() JavaScript methods.

The above listing also defines server-side code to retrieve the complaint status and the remarks from the administrator for the specified complaint reference number from the database.

The admin.asp file provides the Administrative Tasks page that provides the administrator the options to change the password, view complaints, and register complaints. Listing 3-16 shows how to create the admin.asp page:

Listing 3-16: Creating the admin.asp File

start example
 <% response.buffer=true if Session("Logintest")<>"administrator" then response.redirect("./login.html") end if %> <!--#include virtual="adovbs.inc"--> <!--#include file="conn.asp"--> <html> <head> <script language="javascript"> function callback() {    window.history.back() } function callhome() {    window.location.replace("./login.html") } </script> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>Administrative Tasks</title> </head> <body bgcolor="#FFFFFF" link="#FF6600" vlink="#808080" alink="#FF3300"> <form name="admin"> <div align="center"> <center> <table border="0" width="661" height="65" bgcolor="#FFFFFF"> <tr> <td width="74" height="65"><font size="6">&nbsp;  </font></td> <td width="571" height="65"> <p align="center"><font size="5" face="Verdana" color="#FF6600">COMPLAINT MONITORING SYSTEM</font></p> </td> </tr> </table> </center> </div> <table border="0" width="100%"> <tr> <td width="100%" colspan="2" bgcolor="#FF6600">&nbsp;</td> </tr> <tr> <td width="100%" colspan="2"><hr></td> </tr> <tr> <td width="50%"><font face="Verdana" size="5" color="#666666">A</font><font face="Verdana" size="2" color="#666666">DMINISTRATIVE </font><font face="Verdana" size="5" color="#666666">T</font><font face="Verdana" size="2" color="#666666">ASK</font></td> <td width="50%"></td> </tr> <tr> <td width="100%" colspan="2"><hr color="#FF6600"></td> </tr> </table> <table border="0" width="100%"> <tr> <td width="100%"> <fieldset> <legend><font face="Verdana" size="5" color="#666666">O</font><font face="Verdana" size="2" color="#666666">PTIONS</font></legend> <table border="0" width="100%"> <tr> <td width="6%" background="./nav.gif"></td> <td width="94%"> <p align="left"><font color="#FF6600" face="Verdana">&nbsp; </font><a href="./changepass.asp"><font color="#0000ff" face="Verdana">Change Password</font></a></p> <p align="left">&nbsp;</p> <p align="left">&nbsp; <a href="./viewcomp.asp"><font color="#0000ff" face="Verdana">View Complaints</font></a></p> <p align="left">&nbsp;</p> <p align="left">&nbsp;<font color="#0000ff" face="Verdana"> <a href="./complaint.asp">Complaint</a></font></p> </td> </tr> </table> <p align="left"><font color="#0000ff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></p> </fieldset> </td> </tr> </table> <center> <img border="0" src="/books/2/923/1/html/2/./back.gif" OnClick=callback()> <img border="0" src="/books/2/923/1/html/2/./home.gif" OnClick=callhome()> </center> </form> </body> </html> 
end example

The above listing defines the callhome() and callback() JavaScript methods.

The above listing also defines server-side code to check whether the end user accessing the page is an administrator or not. Server-side code compares the string value contained in the LoginTest session variable with the string administrator. If the values do not match, the Web server redirects the end user to the Login page. The code redirects the administrator to the changepass.asp file when the administrator clicks the Change Password link, to the viewcomp.asp file when the administrator clicks the View Complaints link, and to the complaint.asp file when the administrator clicks the Complaint link.

The changepass.asp file provides the Change Password page that allows the administrator to select the user name, enter the old password, enter the new password, and confirm the new password. Listing 3-17 shows how to create the changepass.asp file:

Listing 3-17: Creating the changepass.asp File

start example
 <% response.buffer=true if Session("Logintest")<>"administrator" then response.redirect("./login.html") end if %> <!--#include virtual="adovbs.inc"--> <!--#include file="conn.asp"--> <html> <head> <script language="javascript"> function callback() {    window.history.back() } function callhome() {    window.location.replace("./login.html") } </script> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>Change Password</title> </head> <body bgcolor="#FFFFFF"> <form method="POST" action="./changepasshandle.asp"> <div align="center"> <center> <table border="0" width="670" height="59"> <tr> <td width="76" height="59" bgcolor="#C0C0C0"><font size="6">&nbsp; </font><b><font size="4" face="verdana"></font></b></td> </center> <td width="578" height="59" align="center" bgcolor="#C0C0C0"> <p align="center"><font face="verdana" size="5">&nbsp;<b> <font color="#000080">COMPLAINT MONITORING SYSTEM</font>&nbsp;</b></font> </p> </td> </tr> </table> </div> <p align="left"><b><font size="4" face="verdana">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</font></b></p> <div align="left"> <table border="0" width="100%" height="184"> <tr> <td width="834" height="1" bgcolor="#FF6600" align="left"> <font size="4" face="verdana" color="#808080">&nbsp;</font><font size="6" color="#C0C0C0" face="verdana">C</font><font face="verdana" size="5" color="#C0C0C0">hange</font><font face="verdana" size="4" color="#FFFFFF"> </font><font size="6" color="#C0C0C0">U</font><font face="verdana" size="5" color="#C0C0C0">ser </font><font size="6" color="#C0C0C0">P</font><font face="verdana" size="5" color="#C0C0C0">password</font> </td> </tr> <tr> <td width="834" height="42" bgcolor="#FFFFFF" align="left"> <p align="left"><b><font size="4" face="verdana"><font color="#000080" face="verdana">Select&nbsp; UserId</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <select size="1" name="cmbuserid" style ="width:150px"> <% Dim rs set rs=Server.CreateObject("ADODB.Recordset") rs.open "select * from users",conn while not rs.eof response.write("<option>" & rs("userId") & "</option>") rs.movenext() wend %> </select></font></b></p> </td> </tr> <tr> <td width="834" height="42" bgcolor="#C0C0C0"   align="left"> <p align="left"><b><font size="4" face="verdana"><font color="#000080">Old Password&nbsp;&nbsp;</font>&nbsp;&nbsp;&nbsp;</font>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="password" name="txtoldpass" size="21"></b></p> </td> </tr> <tr> <td width="834" height="42" bgcolor="#FFFFFF" align="left"> <p align="left"><b><font color="#000080" size="4" face="verdana">New  Password</font><font color="#000000"><font size="4">&nbsp;&nbsp;&nbsp;</font>&nbsp;&nbsp;</font><font color="#FFFFFF">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="password" name="txtnewpass" size="21"></font></b></p> </td> </tr> <tr> <td width="834" height="41" bgcolor="#C0C0C0" align="left"> <p align="left"><b><font size="4" color="#000080" face="verdana">Confirm Password</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="password" name="txtconfpass" size="21"></b></p> </td> </tr> </table> </div> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <center><input type="submit" value=" Submit " name="B1"> <input type="reset" value=" Reset " name="B2">&nbsp; <input type="button" value="  Back  " name="back" onclick=callback()> <input type="button" value="  Home  " name="home" onclick=callhome()></center> </p> <p>&nbsp;</p> </form> </body> </html> 
end example

The above listing defines the callhome() and callback() JavaScript methods.

The above listing also defines server-side code to retrieve user names from the database and load the user names in the UserId list box. The administrator selects the user name, enters the old password, enters the new password, confirms the new password, and clicks Submit. When the form is submitted, the entries are transmitted to the changepasshandle.asp file.

The changepasshandle.asp file provides the Process Password Change page that validates the password information that the administrator specifies on the Change Password page and updates the changes in the database. Listing 3-18 shows how to create the changepasshandle.asp file:

Listing 3-18: Creating the changepasshandle.asp File

start example
 <%response.buffer=true%> <!--#include virtual="adovbs.inc"--> <!--#include file="conn.asp"--> <html> <head> <script language="javascript"> function callback() {    window.history.back() } function callhome() {    window.location.replace("./login.html") } </script> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>Process Password Change</title> </head> <body> <% set temp_pswd=Server.CreateObject("ADODB.Recordset") temp_pswd.open "select password from Users where UserId='" & request.form("cmbuserid")   &"'" , conn ,adopendynamic,adlockoptimistic                 if request.form("txtoldpass")<>temp_pswd("Password") then          Response.Write("<h2><center><font color='#FF6600' face='verdana'><br><br><br><br><br>Old Password that you have entered is incorrect.</font></center></h2>")        Response.Write("<h2><center><font color='#FF6600' face='verdana'>Please try again!!!</font></center></h2>") %> <center> <img border="0" src="/books/2/923/1/html/2/./back.gif" OnClick=callback()> <img border="0" src="/books/2/923/1/html/2/./home.gif" OnClick=callhome()> </center>                     <% else if request.form("txtnewpass")=request.form("txtconfpass") then temp_pswd("Password")=request.form("txtnewpass") temp_pswd.update Response.Write("<h2><center><font color='#FF6600' face='verdana'><br><br><br><br><br>Password changed successfully.</font></center></h2>") %> <center> <img border="0" src="/books/2/923/1/html/2/./back.gif" OnClick=callback()> <img border="0" src="/books/2/923/1/html/2/./home.gif" OnClick=callhome()> </center> <% else Response.Write("<h2><center><font color='#FF6600' face='verdana'><br><br><br><br><br>New password and confirm password are different.</font></center></h2>") %> <center> <img border="0" src="/books/2/923/1/html/2/./back.gif" OnClick=callback()> <img border="0" src="/books/2/923/1/html/2/./home.gif" OnClick=callhome()> </center> <% end if  end if %> <p>&nbsp;</p> <p>&nbsp;</p> </body> </html> 
end example

The above listing defines the callhome() and callback() JavaScript methods.

The above listing also defines server-side code to validate password information by comparing the entries that the administrator specifies on the Change Password page and the entries in the database. The code then updates the changes in the database if the validation is successful; otherwise, it displays error messages on the page.

The viewcomp.asp page provides the View Complaints page that displays the list of complaints in tabular format. The table contains various fields, such as complaint reference number, machine code, peripheral code, department code, date of complaint, date of rectification, down time, remarks, status, problem, complaint name, and location identity. This page enables the administrator to enter the date of rectification and remarks against the complaint. The code on this page automatically calculates the down time of the machine by calculating the difference between the date of complaint and the date of rectification. The administrator checks the status column and updates the complaint to mark the complaint as attended or resolved. The administrator can update the complaint without checking the status column to mark the complaint as partially solved. The administrator updates the complaints by clicking the links against the complaint numbers. Listing 3-19 shows how to create the viewcomp.asp file:

Listing 3-19: Creating the viewcomp.asp File

start example
 <% response.buffer=true if Session("Logintest")<>"administrator" then response.redirect("./login.html") end if %> <!--#include virtual="adovbs.inc"--> <!--#include file="conn.asp"--> <%  if request.form("formname")="viewcomp" then        dim dor, downtime, remarks, status1, complaintId, rsComplaint, dt set rsComplaint=Server.CreateObject("ADODB.Recordset") dor= request.form("txtdor") complaintId= request.form("txtcomplaint") remarks=ucase(request.form("txtremarks")) if remarks="" then remarks="NO REMARKS" end if downtime= request.form("txtdowntime") status1=request.form("txtstatus") arr1=split(dor,"/") yy=right(arr1(2),2) dt=arr1(0) & "/" & arr1(1) & "/" & yy  sql="select * from Complaint where complaintId='"& request.form("txtcomplaint") & "'" rsComplaint.Open sql, conn ,adopendynamic,adlockoptimistic rsComplaint("DOR")=dt rsComplaint("DownTime")=request.form("txtdowntime") rsComplaint("Remarks")=remarks rsComplaint("Status")=request.form("txtstatus") rsComplaint.update response.redirect("./responseview.asp") end if %> <html> <head> <script language="javascript"> function passvalue(complaintId,cmb1,cmb2,cmb3,dt,rem,stat) {    for(i=0;i<document.forms[0].length;i++)    {       var date       if (document.forms[0].elements[i].name==cmb1)       {          date=document.forms[0].elements[i].options[document.forms[0].elements[i].selectedIndex].text          continue       }       if (document.forms[0].elements[i].name==cmb2)       {          date+="/"+ document.forms[0].elements[i].options[document.forms[0].elements[i].          selectedIndex].text          continue       }       if (document.forms[0].elements[i].name==cmb3)       {          date+="/"+ document.forms[0].elements[i].options[document.forms[0].elements[i].          selectedIndex].text       }    }    for(i=0;i<document.forms[0].length;i++)    {       var downt       if (document.forms[0].elements[i].name==dt)       {          downt=document.forms[0].elements[i].value          break       }    }    for(i=0;i<document.forms[0].length;i++)    {       var remar       if (document.forms[0].elements[i].name==rem)       {          remar=document.forms[0].elements[i].value          break       }    }    for(i=0;i<document.forms[0].length;i++)    {       var status       if (document.forms[0].elements[i].name==stat)       {          if(document.forms[0].elements[i].checked)          {             status=1          }          else          {             status=0          }       }    }    document.forms[0].txtcomplaint.value=complaintId    document.forms[0].txtdor.value=date    document.forms[0].txtdowntime.value=downt    document.forms[0].txtremarks.value=remar    document.forms[0].txtstatus.value=status    document.forms[0].action="viewcomp.asp"    document.forms[0].submit() } function lostfocus(cmb1,cmb2) {    for(i=0;i<document.forms[0].length;i++)    {    if (document.forms[0].elements[i].name==cmb1)    {       var month=document.forms[0].elements[i].options[document.forms[0].elements[i].selectedIndex].text       continue    }    if (document.forms[0].elements[i].name==cmb2)    {       var day=document.forms[0].elements[i].options[document.forms[0].elements[i].selectedIndex].text       continue    } } if ( ( ((month==2)||(month==4)||(month==6)||(month==9)||(month==11)) & & (day==31)) || ((month==2) & & (day==30))) {    alert("Not a valid date."); } } function calcdate(cmb1,cmb2,cmb3,doc,downtime) {    for(i=0;i<document.forms[0].length;i++)    {       var date       if (document.forms[0].elements[i].name==cmb1)    {       var month=document.forms[0].elements[i].options[document.forms[0].elements[i].selectedIndex].text       month-=1       date=document.forms[0].elements[i].options[document.forms[0].elements[i].selectedIndex].text       continue    }    if (document.forms[0].elements[i].name==cmb2)    {       var day=document.forms[0].elements[i].options[document.forms[0].elements[i].selectedIndex].text       date+="/"+ document.forms[0].elements[i].options[document.forms[0].elements[i].       selectedIndex].text       continue    }    if (document.forms[0].elements[i].name==cmb3)    {       var year=document.forms[0].elements[i].options[document.forms[0].elements[i].selectedIndex].text       date+="/"+ document.forms[0].elements[i].options[document.forms[0].elements[i].       selectedIndex].text       continue    }    if (document.forms[0].elements[i].type == "hidden")    {       if(document.forms[0].elements[i].name==doc)       {          var dateofcomp=document.forms[0].elements[i].value       }    } } var newdate=new Date(year,month,day) var newdate1=dateofcomp.split("/") newdate1[0]-=1 newdate1[2]=parseInt(newdate1[2]) + 2000 if ((year%4!=0) && (month==1) && (day==29)) {    alert("Not a leap year.") } var newdate2=new Date(newdate1[2],newdate1[0], newdate1[1]) var milli=newdate.valueOf() var milli1=newdate2.valueOf() var result=milli-milli1 var noofdays=result/(24*3600*1000) if (result < 0) {    alert("Date of rectification cannot be earlier than Date of complaint") } else {    for(i=0;i<document.forms[0].length;i++)    {       if (document.forms[0].elements[i].name==downtime)       {           document.forms[0].elements[i].value=noofdays          break       }    } } } </script> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>View Complaints</title> </head> <body> <%  dim page_size,current_page,page_count page_size=7 if request("page")="" then current_page=1 else current_page=CInt(request("page")) end if set rs=Server.CreateObject("ADODB.RecordSet") rs.CursorLocation=adUseClient rs.PageSize=page_size sql="select * from Complaint where Status=0" rs.Open sql,conn, adOpenDynamic, adLockBatchOptimistic, adcmdText page_count=rs.PageCount if 1 > current_page then current_page=1 end if if current_page > page_count then current_page=page_count end if rs.AbsolutePage=current_page %> <form  name="viewcomp" method="POST" > <input type="hidden" name="txtcomplaint" value=""> <input type="hidden" name="txtdor" value=""> <input type="hidden" name="txtdowntime" value=""> <input type="hidden" name="txtremarks" value=""> <input type="hidden" name="txtstatus" value=""> <input type="hidden" name="formname" value="viewcomp"> <p align="center">&nbsp;</p> <p align="left"><b><font face="Verdana" size="6" color="#000080">Pending Complaints</font></b></p> <p align="center">&nbsp;</p> <div align="left"> <table border="4" width="63%" bgcolor="#FFFFFF" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" style="border: 4 solid #FFFFFF"> <tr> <td width="7%" align="center" bordercolor="#FFFFFF" bgcolor="#FF6600" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" valign="top"> <p align="center"><b><font color="#FFFFFF" face="Verdana">COMPLAINT&nbsp;&nbsp;  NO.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</font></b></td> <td width="7%" align="center" bordercolor="#FFFFFF" bgcolor="#FF6600" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" valign="top"> <p align="center"><b><font color="#FFFFFF" face="Verdana">&nbsp;MAC.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ID&nbsp;&nbsp;&nbsp;&nbsp;</font> </b></td> <td width="7%" align="center" bordercolor="#FFFFFF" bgcolor="#FF6600" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" valign="top"> <p align="center"><b><font color="#FFFFFF" face="Verdana">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PERIPH.& nbsp;&nbsp; ID&nbsp;&nbsp;&nbsp;</font> </b></td> <td width="7%" align="center" bordercolor="#FFFFFF" bgcolor="#FF6600" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" valign="top"> <p align="center"><b><font color="#FFFFFF" face="Verdana">DEPTT.&nbsp;</font></b></td> <td width="8%" align="center" bordercolor="#FFFFFF" bgcolor="#FF6600" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" valign="top"> <p align="center"><b><font color="#FFFFFF" face="Verdana">DATE OF COMPLAINT</font> </b></td> <td width="12%" align="center" bordercolor="#FFFFFF" bgcolor="#FF6600" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" valign="top"> <p align="center"><b><font color="#FFFFFF" face="Verdana">DATE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OF&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RECT.&nbsp;&nbsp;</font></b></td> <td width="8%" align="center" bordercolor="#FFFFFF" bgcolor="#FF6600" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" valign="top"> <p align="center"><b><font color="#FFFFFF" face="Verdana">DOWN TIME</font> </b></td> <td width="8%" align="center" bordercolor="#FFFFFF" bgcolor="#FF6600" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" valign="top"> <p align="center"><b><font color="#FFFFFF" face="Verdana">REMARKS</font></b></td> <td width="8%" align="center" bordercolor="#FFFFFF" bgcolor="#FF6600" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" valign="top"> <p align="center"><b><font color="#FFFFFF" face="Verdana">STATUS</font></b></td> <td width="8%" align="center" bordercolor="#FFFFFF" bgcolor="#FF6600" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" valign="top"> <p align="center"><b><font color="#FFFFFF" face="Verdana">PROBLEM</font></b></td> <td width="8%" align="center" bordercolor="#FFFFFF" bgcolor="#FF6600" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" valign="top"><b><font color="#FFFFFF" face="Verdana">NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font> </b></td> <td width="8%" align="center" bordercolor="#FFFFFF" bgcolor="#FF6600" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" valign="top"> <p align="center"><b><font color="#FFFFFF" face="Verdana">LOC. ID</font> </b></td> </tr> <%     while rs.AbsolutePage=current_page and not rs.EOF response.write"<tr>" dim combo1,combo2,combo3,doc doc=rs("complaintId")&"_8" combo1=rs("complaintId") combo2=rs("complaintId")&"_6" combo3=rs("complaintId")&"_7" combotext1=rs("complaintId")&"_2" combotext2=rs("complaintId")&"_3" comboch=rs("complaintId")&"_4" combotext3=rs("complaintId")&"_5" %> <td bgcolor="#CCCCCC" align="center"><font face='verdana'><a href="javascript:passvalue('<%= rs("complaintId")%>','<%= combo1%>','<%= combo2%>','<%= combo3%>','<%= combotext1%>','<%= combotext2%>','<%= comboch%>')"><b><%= rs("complaintId")%> </b></a></font></td> <% response.write"<td bgcolor='#CCCCCC' align='center'><font face='verdana'><b> " & rs("MachineId") & " </b></font></td>" response.write"<td bgcolor='#CCCCCC' align='center'><font face='verdana'><b> " & rs("PeripheralId") & " </b></font></td>" response.write"<td bgcolor='#CCCCCC' align='center'><font face='verdana'><b> " & rs("DepartmentId") & " </b></font></td>" response.write"<td bgcolor='#CCCCCC' align='center'><font face='verdana'><b> " & rs("DOC") & " </b></font></td>" response.write"<input type='hidden' name='" & rs("complaintId") & "_8' value='" & rs("DOC") & "' >" %> <td bgcolor='#CCCCCC' align='center'> <select  name="<%= combo1%>" size='1'> <option value='month'>mm</option> <option value='January'>1</option><option value='February'>2</option><option value='March'>3</option><option value='April'>4</option><option value='May'>5</option><option value='June'>6</option><option value='July'>7</option><option value='August'>8</option><option value='September'>9</option><option value='October'>10</option><option value='November'>11</option><option value='December'>12</option> <% if rs("DOR")<> "" then arr1=split(rs("DOR"),"/")%> <option selected><%= arr1(0)%></option> <%end if%> </select> <select   name="<%= combo2%>" size='1' onChange="lostfocus('<%= combo1%>','<%= combo2%>')"> <option value='date'>dd</option> <option value=1>1</option><option value=2>2</option><option value=3>3</option><option value=4>4</option><option value=5>5</option><option value=6>6</option><option value=7>7</option><option value=8>8</option><option value=9>9</option><option value=10>10</option><option value=11>11</option><option value=12>12</option><option value=13>13</option><option value=14>14</option><option value=15>15</option><option value=16>16</option><option value=17>17</option><option value=18>18</option><option value=19>19</option><option value=20>20</option><option value=21>21</option><option value=22>22</option><option value=23>23</option><option value=24>24</option><option value=25>25</option><option value=26>26</option><option value=27>27</option><option value=28>28</option><option value=29>29</option><option value=30>30</option><option value=31>31</option> <% if rs("DOR")<> "" then arr1=split(rs("DOR"),"/")%> <option selected><%= arr1(1)%></option> <%end if%> </select>/ <select  name="<%= combo3%>" size='1' onBlur="calcdate('<%= combo1%>','<%=  combo2%>','<%= combo3%>','<%=doc%>','<%= combotext1%>')"> <option value='year'>yy</option> <option value=2002>2002</option><option value=2003>2003</option><option value=2004>2004</option><option value=2005>2005</option><option value=2006>2006</option><option value=2007>2007</option><option value=2008>2008</option><option value=2009>2009</option><option value=2010>2010</option><option value=2011>2011</option><option value=2012>2012</option><option value=2013>2013</option><option value=2014>2014</option><option value=2015>2015</option><option value=2016>2016</option><option value=2017>2017</option><option value=2018>2018</option><option value=2019>2019</option><option value=2020>2020</option> <% if rs("DOR")<> "" then arr1=split(rs("DOR"),"/") arr1(2)=2000+arr1(2) %> <option selected><%= arr1(2)%></option> <%end if%> </select> </td> <td bgcolor='#CCCCCC' align='center'> <%  if rs("Downtime")<>"" then %> <input type='text' name="<%= combotext1%>" value="<%= rs("DownTime")%>" size='5'> <%else%> <input type='text' name="<%= combotext1%>" value="" size='5' readonly> <%end if%> </td> <td bgcolor='#CCCCCC' align='center'> <% if rs("Remarks")<>"" then %> <textarea  name="<%= combotext2%>" rows='2' cols='10'><%=  rs("Remarks")%></textarea> <%else%> <textarea  name="<%= combotext2%>" rows='2' cols='10'></textarea> <%end if%> </td> <% dim status status=rs("Status") if status="True" then %> <td bgcolor='#CCCCCC' align='center'> <input type='checkbox' name="<%= comboch%>" checked> </td> <% else %> <td bgcolor='#CCCCCC' align='center'> <input type='checkbox' name="<%= comboch%>"> </td> <% end if %> <td bgcolor='#CCCCCC' align='center'> <b><textarea  name="<%= combotext3%>" rows='2' cols='10' align="left" readonly>  <%= rs("Others")%></textarea></b></td> <% response.write"<td bgcolor='#CCCCCC' align='center'><font face='verdana'><b> "  & rs("CompltName") & " </b></font></td>" response.write"<td bgcolor='#CCCCCC' align='center'><font face='verdana'><b> " &  rs("LocationId") & " </b></font></td>" response.write"</tr>" rs.MoveNext wend %> </table> </div> <p>&nbsp;</p>  <% if current_page<>1 then response.write "<a href=""viewcomp.asp?page=" response.write current_page-1 response.write """>Previous page</a>" end if if current_page<page_count then response.write "<a href=""viewcomp.asp?page=" response.write current_page+1 response.write """>Next page</a>" end if %> </form> </body> </html> 
end example

The above listing defines the following JavaScript methods:

  • callhome(): Loads the login.html page, which is the home page of the application.

  • callback(): Displays the previous page in the browser.

  • passvalue(): Sets the values of the controls on the form with the values passed to this function. The values are downtime, date, complaint ID, remarks, and status.

  • lostfocus(): Executes when focus is lost from the combo2 control that displays the date. This method checks whether the administrator selects a valid date or not.

  • calcdate(): Checks whether the date of rectification is greater than the date of complaint.

The above listing also defines the server-side control to retrieve complaint information from the database and display the list of complaints in tabular format. The code redirects the administrator to the responseview.asp file when the administrator clicks the complaint reference number of a complaint to be updated.

The responseview.asp file provides the Response View page that displays the message that the complaint is updated successfully. Listing 3-20 shows how to create the responseview.asp file:

Listing 3-20: Creating the responseview.asp File

start example
 <% response.buffer=true %> <!--#include virtual="adovbs.inc"--> <!--#include file="conn.asp"--> <html> <head> <script language="javascript"> function callback() {    window.history.back() } function callhome() {    window.location.replace("./login.html") } </script> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>Response View</title> </head> <body> <h2><center> <font color='#FF6600'><br><br><br><br><br>Record Updated successfully.</font> </center></h2> <center> <img border="0" src="/books/2/923/1/html/2/./back.gif" OnClick=callback()> <img border="0" src="/books/2/923/1/html/2/./home.gif" OnClick=callhome()> </center> </body> </html> 
end example

In the above listing, the responseview.asp file renders the message Record updated successfully.

Using the ASP to ASP.NET Migration Assistant

The ASP to ASP.NET Migration Assistant tool converts ASP applications to ASP.NET. It does not convert the entire application to ASP.NET. You need to perform some manual modifications to optimize the code after conversion. The Migration Assistant tool creates stand-alone .aspx pages corresponding to each .asp page in the ASP application.

Important

You need to segregate the presentation logic and the business logic after the migration process. For each .aspx file, you need to create a code-behind file in which you can write the business logic. This code-behind file segregates the presentation and business logic.

Before you use the Migration Assistant tool, back up your ASP application. Ensure your computer meets the requirements for installing the ASP to ASP.NET Migration Assistant tool. The operating systems you can use are Windows XP, Windows 2000, and Windows Server 2003. You also need .NET Framework, which is installed, by default, with Windows Server 2003 and Visual Studio .NET.

To migrate applications from ASP to ASP.NET using the ASP to ASP.NET Migration Assistant tool from within Visual Studio .NET:

  1. Download and install the ASP to ASP.NET Migration Assistant.

  2. After installing the Migration Assistant, open Visual Studio .NET.

  3. Select File -->Open -->Convert from the menu bar to start the conversion process, as shown in Figure 3-1:

    click to expand: the above figure shows the convert option as a submenu item of the open menu item.
    Figure 3-1: The Convert Option

  4. Select the ASP to ASP.NET Migration Assistant in the Convert dialog box. In addition, select Create new solution if you want to create a new set of files for the ASP.NET application. If you need to add the files to the opened application, select Add to current solution, as shown in Figure 3-2:

    click to expand: the above figure shows the convert dialog box that shows the list of available converters and allows you to select a converter to start the migration process.
    Figure 3-2: The Convert Dialog Box

  5. Click OK. The Welcome to ASP to ASP.NET Migration Assistant Wizard page appears, as shown in Figure 3-3:

    click to expand: the above figure shows the first page of the asp to asp.net migration assistant wizard.
    Figure 3-3: The ASP to ASP.NET Migration Assistant Wizard Page

  6. Click Next. The Choose a directory of ASP files page appears, as shown in Figure 3-4:

    click to expand: the above figure shows the choose a directory of asp files page that allows you to specify the path of the asp application you need to convert.
    Figure 3-4: The Choose a Directory of ASP Files Page

  7. Specify the path of the ASP project and click Next. The New Project Information page appears, as shown in Figure 3-5:

    click to expand: the above figure shows the new project information page that allows you to specify the name of the asp.net application.
    Figure 3-5: The New Project Information Page

  8. Specify the name of the ASP.NET Web application and click Next. The Specify a Location for Your New Project page appears, as shown in Figure 3-6:

    click to expand: the above figure shows the specify a location for your new project page that enables you to specify the path of the new asp.net application.
    Figure 3-6: The Specify a Location for Your New Project Page

  9. Specify the path of the directory where you want your new project created and click Next. The Ready To Upgrade page appears, as shown in Figure 3-7.

    click to expand: the above figure shows the ready to upgrade page that intimates that the wizard is now ready to upgrade your asp application to asp.net.
    Figure 3-7: The Ready To Upgrade Page

  10. Click Next. The System Upgrade page appears, as shown in Figure 3-8:

    click to expand: the above figure shows the system upgrade page that shows the progress of upgrading the asp application to asp.net.
    Figure 3-8: The System Upgrade Page

    When the progress bar reaches the end, the Migration Assistant wizard completes, and the conversion process ends.

    To migrate ASP applications to ASP.NET using the command line:

  11. Open the Command window.

  12. Type the following command to run the AspUpgrade.exe file:

     ASPUpgrade[.exe] <DirectoryName> [/Out ] [/NoLog | /LogFile ] [/Verbose] [ /ProjectName ] [/ForceOverwrite]  

Note

You can type the following command for help:

 ASPUpgrade[.exe] /? or /Help       

The options used in the command line are:

  • Directory Name: Specifies the path of the ASP file to be upgraded.

  • /Out DirectoryName: Specifies the path for the folder where you plan to create the ASP.NET project, which is the target directory. The default path is \OutDir.

  • /Verbose: Displays the entire output to the MS-DOS window during upgrade.

  • /NoLog: Suppresses the writing a log file.

  • /LogFile filename: Specifies the name of the log file to generate. The default file name is <targetdirectory>\<projectname>.log.

  • /ProjectName: Specifies the project name for directory conversion. The default project name is Project1.

  • /ForceOverwrite: Suppresses prompting to confirm that you want to overwrite an existing destination directory.

  • /? or /Help: Displays all the command-line options.

Post Migration Considerations

The ASP to ASP.NET Migration Assistant tool converts the files of the ASP project to files with the .aspx extension. The migration tool removes all references of .asp files when it converts the files and changes them to .aspx extensions.

In ASP applications, created using VBScript, the variable declarations do not include data types or variables are sometimes undeclared. In this case, it is difficult to understand the variables properties and their methods. The Migration Assistant tool performs the necessary relocations of VBScript code to the equivalent script or renders tags in ASP.NET.

The Migration Assistant tool converts the code written only in VBScript. You obtain an Error Warning and Issues (EWI) if the scripting language used for server-side scripting is not VBScript.

The Migration Assistant tool does not convert the complex rendering methods, which distorts the design view of the Web pages opened in ASP.NET.

The tool also does not convert the security model. Security configuration in ASP.NET occurs in the Web.config file. When the automatic conversion process is over, you should review all the EWIs in the code and fix the errors.




Migrating Unmanaged Applications to. NET
Migrating Unmanaged Applications to. NET
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 31

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net