Some Notes for Converting ASP pages to Asp.Net (ASPX) Pages

Some old checklist I had made a while back on converting an asp page to asp.net.  It was kind of a pain, and it popped up again, because a fellow co worker was asking about it.  It might be of some use.



1)      First I created an aspx page, then copied the asp over it excluding the original ASP directive at the top.
2)      Make sure class names, filenames, locations are correct.
3)      Need to use Codefile instead of CodeBehind in the Page directive.
4)      Make sure the language in the directive matches the code.  In that asp page I was converting the language was “C#”, but the script language was “VB”.
5)      Since this is asp.net make sure you are using Partial keyword in code behind for the class declaration type.
6)      May need to have new includes.
7)      “ '__o' is not declared. It may be inaccessible due to its protection level.                Will show as a compiler Error, but is not actually an error that will stop you from running the project. To get rid of it, input after the Page directive :
<%-- The following line works around an ASP.NET compiler warning --%>
<%= ""%>
1)      Change the Form element to have runat=”server”.  It can have a formid, but action needs to be removed.
2)      Make ids unique to page.  objCmd and objRs were not unique in asp page for the ASP page that I had to work on. 
3)      May need to declare variables in aspx code behind.  They can be Public or Protected.  In asp seems it has dynamic types or something.
4)      Will also need to remove the “SET” command, you can simply declare them inline in the aspx page with Dim objectName as Type = Server.Create(“type”), for example.
5)      Put loose scripts into aspx codebehind.
6)      IN asp a “ ’ ” before an include is an ACTUAL include not a commented out include.  Make sure to have all the includes, or to take out what you need from them.  In this case I needed to get some connection string which I moved to the web.config.
7)      Put the connection string to set itself in the Load event of the Page from the web.config. 
8)      There was a lot of Response.Write() code, so what I did was put a label below the new asp Button control. Then in the new code behind file, use lblMessage.Text += “whatever”, to capture the output and place it in the right place.  Other wise the Response.Write() places all the text on the very top of the page.
9)      If the page needs to post to itself, make sure to remove the action and post section from the from element.  Then in the button have a postbackurl that points to this aspx page.  Then in the OnClick event of the button handle the code that would run on a postback.
10)   Use button to Postback to current page.  This is necessary in order to use the Request.Form(“controlID”) to get values.
11)   No need to declare the a control in the aspx part AGAIN in the codefile for aspx pages.
12)   ConfigurationSettings.AppSettings(strConName) is old use WebConfigurationManager.ConnectionStrings(strConName).ConnectionString(), need to use Imports System.Web.Configuration

Comments

Popular posts from this blog

Asp.net Publishing Broke Site - "App_WebReferences is not allowed because the application is precompiled"

Telerik - Custom Group Footers In RadGrid