[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 374
  • Last Modified:

converting asp to aspx, need designer

I've been converting a website to aspx from asp.

The problem I just hit is that I need to add controls to the new aspx page but the code behind won't recognize these controls and there isn't a designer page.  How do I make this work?
0
UnderSeven
Asked:
UnderSeven
  • 3
  • 3
1 Solution
 
guru_samiCommented:
You won't have the designer page if your project type is "Website".
If you can share part of your code of .aspx and codebehind it will help identify the problem.
0
 
UnderSevenAuthor Commented:
This is the code segments, basically the aspx code ends with a if statement I am migrating to the code behind, to do that I am creating a control.  Codebehind is below.  The portion where the label is called to change the text is getting and undeclared error.

Closing and opening project, clicking on label in aspx design and switching back to code is not working.




<%@ Page Language="VB" AutoEventWireup="True"  CodeBehind="GBill_Registration.aspx.vb" Inherits="WebApplication1.Cogsdale.gbillreg" %>
<% REM ##########################################################################%>
<% REM                                                                          #%>
<% REM   GBill_Registration.asp                                                 #%>
<% REM   Cogsdale CSM on Web v1.10                                        	    #%>
<% REM                                                                         	#%>
<% REM   Copyright (c) 2001-05 Cogsdale.  All rights reserved.     				#%>
<% REM                                                                          #%>
<% REM ##########################################################################%>




<form method="POST" runat="server" action="gbill_registration.aspx?action=register"  onsubmit2="return validate(this);" name="Form1">
	<table border="0" style="border-collapse: collapse" bordercolor="#111111" width="800" bgcolor="#FFFFFF" cellpadding="2">
		<tr valign="top">
			<td align="center" width="325"><br><br><font color="#000000" size="2" face="Verdana">Example of a statement with your customer number highlighted.</font><br><br>
				<img border="0" src="./images/pictures/statementShot2.jpg" align="center" border="0">
			</td>
			<td width=475>
				<table border="0" cellspacing="0" cellpadding="5" width=100%>
					<tr>
						<td colspan="2" align="center" height="60">
							<div align="center"><font face="Arial" size="5" color="#336699">Registration Form</font></div><br>
							<asp:Label ID="lblwarn" runat="server" />
							<% if CustomerIDError <> "" or NameError <> "" or ServiceAddressError <> "" or EmailError <> "" or PasswordError <> "" or AgreeTermsError <> "" then%>
							<div align="left"><font color="#FF0000" size="2" face="Verdana"><B><CENTER>WARNING! We were unable to set up your account<BR> Please check your information and try again or call Customer Service at <%=Application1("CustServicePhoneNumber") %></CENTER></B></font></div>
							<% End If %>
<asp:label id="lblwarn" runat="server />

Open in new window


Namespace Cogsdale


    Partial Public Class gbillreg
        Inherits getoption



        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

            If allSecure("action") = "register" Then
                Dim strErrorMsg = ""
                Dim CustomerID = allSecure("CustomerID")
                Dim Name = Trim(Replace(allSecure("Name"), ".", ""))
                Dim ServiceAddress = Trim(allSecure("ServiceAddress"))
                Dim Email = Trim(allSecure("Email"))
                Dim Email2 = Trim(allSecure("Email2"))
                Dim Password = Trim(allSecure("Password"))
                Dim Password2 = Trim(allSecure("Password2"))
                Dim AgreeTerms = allSecure("AgreeTerms")
                Dim rsCustomer As System.Data.SqlClient.SqlDataReader
                Dim CustomerIDError = ""
                Dim NameError = ""
                Dim ServiceAddressError = ""
                Dim EmailError = ""
                Dim PasswordError = ""
                Dim AgreeTermsError = ""
                Dim CustName As String
                Dim isServiceAddressRequired = Application1("IsServAddressRequired")
                Dim callFunctionStr As New System.Data.SqlClient.SqlCommand()
                Dim connect As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection()
                Const serviceAddressMaxLength = 30
                Dim ServiceAddress1 As String
                Dim ServiceAddress2 As String
                Dim emailFrom, emailto, subject, content, sendEmail As String ' for email section


                Dim maxCustNumLen
                maxCustNumLen = CInt(Application1("MaxCustNumberLength"))


                lblwarn.text = "text"

Open in new window

0
 
guru_samiCommented:
What error do you get?
for lblwarn.text = "text" it should be lblwarn.Text="text"

Also you cannot simply bring code from asp to .aspx page.
You should not use If...Else inside your .aspx page. Whatever conditions you need, try to do that in the code-behind.
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
UnderSevenAuthor Commented:
What error do you get?
The error is that lblwarn is undeclared
for lblwarn.text = "text" it should be lblwarn.Text="text"


Also you cannot simply bring code from asp to .aspx page.
You should not use If...Else inside your .aspx page. Whatever conditions you need, try to do that in the code-behind.
I know this, the code snippet is a work in progress, I was trying to fix the lines one at a time.  I've already migrated quite a few other pages without this problem, though I may not have been trying to add new controls in those instances.
0
 
guru_samiCommented:
What I would do is one thing at a time instead of porting everything at a time.
Sometimes if the page cannot be compiled, the designer won't pickup the changes.

Start with a blankpage and adjusting it as per asp.net standards. And since you are porting it, you don't want to do things same as in asp, but improve it as well.
0
 
UnderSevenAuthor Commented:
So this is kind of what I'm having to do.  In addition I just manually created the designer file and then it started working. I know it isn't supposed to be something that you should need to create, or edit, but by making it myself it fixed the problem.  I am also taking your advice and rather than pasting the asp page and updating it I am porting it over line by line and addressing if the line is properly written before putting it in.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now