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
bigmoxyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.