[Webinar] Streamline your web hosting managementRegister Today

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

Would someone please help me convert .aspx/ .aspx.vb into .aspx/ .ascx/ .ascx.vb?

I have just completed my first .Net web site. Now I would like to create reusable code out of it. I have several .aspx/ .aspx.vb files that are virtually identical except for the SQL selection criteria and UI page verbiage. Each page represents a different vehicle category and must exist for SEO purposes.

Would a kind person please take time to review my conversion attempt and guide me through the process?

Thank you!
Tim

PreUserControl.aspx.txt
PreUserControl.aspx.vb.txt
UserControl.aspx.txt
UserControl.ascx.txt
UserControl.ascx.vb.txt
0
bigmoxy
Asked:
bigmoxy
1 Solution
 
samtran0331Commented:
First, you user control is inheriting from a page and not a user control class:
Public Class includes_WebUserControl
    Inherits System.Web.UI.Page

should be:
Public Class includes_WebUserControl
    Inherits System.Web.UI.UserControl





Next thing I notice is that your user control is writing out a string that is trying to include a user tag:

 " WHERE [Vehicle Type] = '<%=VehicleType %>'"


Try making it a public property on the user control, something along the lines of:
Imports System.Data
Imports System.Data.OleDb
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.UserControl

Public Class includes_WebUserControl
    Inherits System.Web.UI.UserControl
    Private mVehicleType As String
    Public Property VehicleType() As String
        Get
            Return mVehicleType
        End Get
        Set(ByVal value As String)
            mVehicleType = value
        End Set
    End Property
...


then where you need the variable:
 " WHERE [Vehicle Type] = '" & mVehicleType & "'"


Also, on your test page, it looks like you're trying to set the page title from the user control?
  <TYASPNET:UserControl id="UserControl1" runat="server"
    VehicleType="Big Duty Vans"
    PageTitle="Big Duty Cargo Vans" />




0
 
bigmoxyAuthor Commented:
I didn't understand your response at the time but have figured out what I was doing wrong. Thanks for pointing me in the right direction.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

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