Link to home
Start Free TrialLog in
Avatar of daddyrat
daddyrat

asked on

The directive is missing a 'src' attribute

Hi,

Can someone explain to me how to resolve a Parser Error.  I'm a student try learning how to created a shopping cart for a school project.  Everything seems to working accept for this error:

Parser Error  (Line 2)
Parser Error Message: The directive is missing a 'src' attribute.
Source Error:
Line 1:  <%@ Control Language="vb" AutoEventWireup="false" Codebehind="uc_shopping_cart.ascx.vb" Inherits="BajaSalsa.uc_shopping" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
Line 2:  <%@Register TagPrefix="uc1" TagName="un_shopping_cart" Scr="uc_shopping_cart.ascx" %>
Line 3:  <TABLE id="Table1" cellSpacing="0" cellPadding="0" width="100%" border="0">
Line 4:        <TR>

Here is a copy of the Gobal.asax

Imports System.Web
Imports System.Web.SessionState

Public Class Global
    Inherits System.Web.HttpApplication

#Region " Component Designer Generated Code "

    Public Sub New()        'I tired to change area to Public Sub Global--did not work'
        MyBase.New()



        'This call is required by the Component Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Required by the Component Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Component Designer
    'It can be modified using the Component Designer.
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        components = New System.ComponentModel.Container
    End Sub

#End Region

    Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires when the application is started
    End Sub

    Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires when the session is started
        Dim UserCart As New CShoppingCart
        Try
            ' Fires when the session is started
            Session("DBCon") = DBCon()
            Session("UserCart") = UserCart
            Session("Customer") = 1
        Catch ex As System.Exception
        Finally

        End Try
    End Sub


    Function DBCon() As System.Data.OleDb.OleDbConnection
        Try
            Dim Path As String = Server.MapPath(".") & "\BajaSalsa.mdb"
            'Build Connection String
            Dim CString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
                Server.MapPath("BajaSalsa.mdb")
            'Open Database
            DBCon = New System.Data.OleDb.OleDbConnection(CString)
            DBCon.Open()
        Catch

        End Try
    End Function
    Function CloseDBCon(ByVal m_DBCon As System.Data.OleDb.OleDbConnection) As Boolean
        Try
            m_DBCon.Close()
        Catch

        End Try
    End Function

    Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires at the beginning of each request
    End Sub

    Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires upon attempting to authenticate the use
    End Sub

    Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires when an error occurs
    End Sub

    Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires when the session ends
        Session("UserCart") = Nothing
        CloseDBCon(Session("DBCon"))
    End Sub

    Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires when the application ends
    End Sub

End Class



Thank for any help!!!!!!!!!!!!!!
Avatar of sara110
sara110

instead of source (src you wrote  Scr="uc_shopping_cart.ascx")
and it hasn't this attribute :-)  good luck
ASKER CERTIFIED SOLUTION
Avatar of sara110
sara110

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of daddyrat

ASKER

"Thank for the advice, everything worked out."  

Now I have created a StartPage.aspx trying to link to the database with a hyperlink to another called index.aspx.  

I get this error:  Could not find file 'c:\inetpub\wwwroot\BajaSalsa\BajaSalsa.mdb'.

My Hyperlink:

<asp:HyperLink id="HyperLink1" style="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP: 32px" runat="server" Font-Size="XX-Large" BorderStyle="Double" BackColor="Yellow" BorderColor="Red" Font-Names="Trebuchet MS" ForeColor="Firebrick" NavigateUrl="index.aspx" Target="_new">Customers</asp:HyperLink>


The page I'm trying to hyperlink to:

Public Class index
    Inherits System.Web.UI.Page
    Protected WithEvents lblCart As System.Web.UI.WebControls.Label
    Private DTRProducts As System.Data.OleDb.OleDbDataReader
    Private DTRCategory As System.Data.OleDb.OleDbDataReader
    Private DB As New System.Data.OleDb.OleDbConnection
    Protected WithEvents HyperLink1 As System.Web.UI.WebControls.HyperLink
    Protected WithEvents lblCartStatus As System.Web.UI.WebControls.Label
    Protected WithEvents DGrid As System.Web.UI.WebControls.DataGrid
    Protected WithEvents HyperLink2 As System.Web.UI.WebControls.HyperLink
    Protected WithEvents HyperLink3 As System.Web.UI.WebControls.HyperLink

    Protected WithEvents STRONG1 As System.Web.UI.HtmlControls.HtmlGenericControl
    Private Products As uc_shopping_cart
    Private UserCart As New CShoppingCart
#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        Try
            If IsPostBack Then
            Else
                UserCart = Session("UserCart")
                Me.lblCartStatus.Text = "Shopping Cart: " & UserCart.Display(Session("DBCon"))
                LoadData(Request.QueryString("category"))
            End If
        Catch ex As System.Exception

        End Try
    End Sub



    Private Sub LoadData(Optional ByVal Key As Long = 0)
        Try
            If Key = 0 Then Key = 1
            Dim DB As New System.Data.OleDb.OleDbConnection
            Dim DA As System.Data.OleDb.OleDbDataAdapter
            Dim DS As System.Data.DataSet
            DB = Session("DBCon")
            Dim SQL As String
            SQL = "Select * From qryProducts Where CategoryID=" & Key
            DA = New System.Data.OleDb.OleDbDataAdapter(SQL, DB)
            DS = New System.Data.DataSet
            DA.Fill(DS)
            DGrid.DataSource = DS
            DGrid.DataKeyField = "ProductID"
            DGrid.DataBind()
        Catch ex As System.Exception
            Response.Write(ex.Message)
        Finally

        End Try
    End Sub


    Private Sub DGrid_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DGrid.ItemCommand
        Try
            Dim itemCell As TableCell = e.Item.Cells(0)
            Dim item As String = itemCell.Text
            Dim txtQuantity As TextBox = e.Item.Cells(4).Controls(1)
            Dim Quantity As String = txtQuantity.Text
            If CType(e.CommandSource, LinkButton).CommandName = "AddToCart" Then
                UserCart = Session("UserCart")
                UserCart.Add(Quantity, item)
                Response.Write("<bgsound src='images/ching.wav' id='ching' loop='1'>")
                Me.lblCartStatus.Text = UserCart.Display(Session("DBCon"))
                Session("UserCart") = UserCart
            End If
        Catch ex As System.Exception
            Response.Write(ex.Message)
        End Try

    End Sub

    Private Sub DGrid_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DGrid.SelectedIndexChanged

    End Sub
End Class
Now I have created a StartPage.aspx trying to link to the database with a hyperlink to another called index.aspx.  

I get this error:  Could not find file 'c:\inetpub\wwwroot\BajaSalsa\BajaSalsa.mdb'.

My Hyperlink:

<asp:HyperLink id="HyperLink1" style="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP: 32px" runat="server" Font-Size="XX-Large" BorderStyle="Double" BackColor="Yellow" BorderColor="Red" Font-Names="Trebuchet MS" ForeColor="Firebrick" NavigateUrl="index.aspx" Target="_new">Customers</asp:HyperLink>


The page I'm trying to hyperlink to:

Public Class index
    Inherits System.Web.UI.Page
    Protected WithEvents lblCart As System.Web.UI.WebControls.Label
    Private DTRProducts As System.Data.OleDb.OleDbDataReader
    Private DTRCategory As System.Data.OleDb.OleDbDataReader
    Private DB As New System.Data.OleDb.OleDbConnection
    Protected WithEvents HyperLink1 As System.Web.UI.WebControls.HyperLink
    Protected WithEvents lblCartStatus As System.Web.UI.WebControls.Label
    Protected WithEvents DGrid As System.Web.UI.WebControls.DataGrid
    Protected WithEvents HyperLink2 As System.Web.UI.WebControls.HyperLink
    Protected WithEvents HyperLink3 As System.Web.UI.WebControls.HyperLink

    Protected WithEvents STRONG1 As System.Web.UI.HtmlControls.HtmlGenericControl
    Private Products As uc_shopping_cart
    Private UserCart As New CShoppingCart
#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        Try
            If IsPostBack Then
            Else
                UserCart = Session("UserCart")
                Me.lblCartStatus.Text = "Shopping Cart: " & UserCart.Display(Session("DBCon"))
                LoadData(Request.QueryString("category"))
            End If
        Catch ex As System.Exception

        End Try
    End Sub



    Private Sub LoadData(Optional ByVal Key As Long = 0)
        Try
            If Key = 0 Then Key = 1
            Dim DB As New System.Data.OleDb.OleDbConnection
            Dim DA As System.Data.OleDb.OleDbDataAdapter
            Dim DS As System.Data.DataSet
            DB = Session("DBCon")
            Dim SQL As String
            SQL = "Select * From qryProducts Where CategoryID=" & Key
            DA = New System.Data.OleDb.OleDbDataAdapter(SQL, DB)
            DS = New System.Data.DataSet
            DA.Fill(DS)
            DGrid.DataSource = DS
            DGrid.DataKeyField = "ProductID"
            DGrid.DataBind()
        Catch ex As System.Exception
            Response.Write(ex.Message)
        Finally

        End Try
    End Sub


    Private Sub DGrid_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DGrid.ItemCommand
        Try
            Dim itemCell As TableCell = e.Item.Cells(0)
            Dim item As String = itemCell.Text
            Dim txtQuantity As TextBox = e.Item.Cells(4).Controls(1)
            Dim Quantity As String = txtQuantity.Text
            If CType(e.CommandSource, LinkButton).CommandName = "AddToCart" Then
                UserCart = Session("UserCart")
                UserCart.Add(Quantity, item)
                Response.Write("<bgsound src='images/ching.wav' id='ching' loop='1'>")
                Me.lblCartStatus.Text = UserCart.Display(Session("DBCon"))
                Session("UserCart") = UserCart
            End If
        Catch ex As System.Exception
            Response.Write(ex.Message)
        End Try

    End Sub

    Private Sub DGrid_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DGrid.SelectedIndexChanged

    End Sub
End Class

where is ur db file and where is ur connection string to your db??
and also is IWAN-your computer name has access read and right to your db??