NET transplanting case learns:Build Web site (3)
Tuesday, March 03, 2009 by rain
Group of development hopes to be in transplanting in the process of this Web site,Can write code less as far as possible,The likelihood that produces flaw in order to decrease.In this part,My general explains to you ASP the page transplants what is the method with the simplest ASP.NET.But use this kind of method to cannot make full use of the new characteristic of ASP.NET,The site that can build to be able to move below ASP.NET only.
The ability after a lot of pages need to do the modification of four three standards moves correctly.The commonnest modification is to should delete Set key word..NET frame and rock-bottom Common Language Runtime (CLR) regard any as like processing to,Deleted Set so this key word.This paragraph of code is taken below from former site:
'create The Feedback Object
Set OFeedback = Server.CreateObject("BetaSiteMgr.Feedback" )
should instead:
'create The Feedback Object
OFeedback = Server.CreateObject("BetaSiteMgr.Feedback" )
another altering commonly is,When an object cites in ASP page,The acquiescent property that should specify this target clearly.CLR and ASP.NET support the acquiescent property that does not transfer parameter no longer.Unfortunate is,Although make clear the value that assigns attribute to be able to increase,the readability of code is mixed but durative,The characteristic that a lot of developer are willing to use acquiescent property more and do not make a cost.In this Web site,When need uses ADO to record,Acquiescent attribute often is used.Original ASP code resembles such:
'set Rs Fields
RsLameError("BetaID" ) = Request.Form("betaid" )
RsLameError("UserDescription" ) = Request.Form("bugDescription" )
RsLameError("SeverityID" ) = Request.Form("severity" )
should instead:
'set Rs Fields
RsLameError("BetaID" ).Value=Request.Form("betaid" )
RsLameError("UserDescription" ).Value=Request.Form("bugDescription" )
RsLameError("SeverityID" ).Value=Request.Form("severity" )
the use means that the third kind of common modification is function of change type changeover.Again in ASP.NET,The type changeover function of VBScript is added in.NET frame.The ASP code below this change requirement
AdoRS.fields("AreaID" ) = Clng(oUploadManager.Form("cboArea" ) )
AdoRS.fields("SubAreaID" ) = Clng(oUploadManager.Form("cboSubArea" ) )
change is:
AdoRS.fields("AreaID" ).Value =
OUploadManager.Form("cboArea" ).ToString().ToInt(of of of of )
AdoRS.fields("SubAreaID" ).Value =
OUploadManager.Form("cboSubArea" ).ToString().ToInt(of of of of )
is the last common modification is to will call the method in the format instead ASP.NET of Response.Write method to call a pattern.In VBScript,Call not when the process of return of value,Do not need to use small bracket to rise parameter draw together.But in ASP.NET,All parameter in delivering a method should rise with bracket draw together.In former site,The Write method that called Response boy or girl friend in a lot of places,And did not add small bracket.To ASP.NET to transplant the site,Be necessary will below this paragraph of code:
% Response.Write "Thank You of < ! "% >
instead:
% Response.Write("Thank You of < ! ") % >
is opposite after original ASP page did these modification,This Web site can move below ASP.NET.Transplanting job should use two weeks to be able to be finished only.To know where needs to revise,Visual Studio.NET IDE of development group application built a program of new application of Visual Basic Web,The patulous name of will existent ASP file instead.aspx,In adding them to the project.Once the page showed in IDE,come out,Visual Studio.NET shines high show grammar,Listed the place that wants to revise,Help us such discovery are compiled period mistake.