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_ca rt.ascx.vb " Inherits="BajaSalsa.uc_sho pping" 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.ICon tainer
'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.Debugg erStepThro ugh()> Private Sub InitializeComponent()
components = New System.ComponentModel.Cont ainer
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.OleDbCon nection
Try
Dim Path As String = Server.MapPath(".") & "\BajaSalsa.mdb"
'Build Connection String
Dim CString As String = "Provider=Microsoft.Jet.OL EDB.4.0; Data Source=" & _
Server.MapPath("BajaSalsa. mdb")
'Open Database
DBCon = New System.Data.OleDb.OleDbCon nection(CS tring)
DBCon.Open()
Catch
End Try
End Function
Function CloseDBCon(ByVal m_DBCon As System.Data.OleDb.OleDbCon nection) As Boolean
Try
m_DBCon.Close()
Catch
End Try
End Function
Sub Application_BeginRequest(B yVal sender As Object, ByVal e As EventArgs)
' Fires at the beginning of each request
End Sub
Sub Application_AuthenticateRe quest(ByVa l 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!!!!!!!!!!!!!!
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_ca
Line 2: <%@Register TagPrefix="uc1" TagName="un_shopping_cart"
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.ICon
'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.Debugg
components = New System.ComponentModel.Cont
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.OleDbCon
Try
Dim Path As String = Server.MapPath(".") & "\BajaSalsa.mdb"
'Build Connection String
Dim CString As String = "Provider=Microsoft.Jet.OL
Server.MapPath("BajaSalsa.
'Open Database
DBCon = New System.Data.OleDb.OleDbCon
DBCon.Open()
Catch
End Try
End Function
Function CloseDBCon(ByVal m_DBCon As System.Data.OleDb.OleDbCon
Try
m_DBCon.Close()
Catch
End Try
End Function
Sub Application_BeginRequest(B
' Fires at the beginning of each request
End Sub
Sub Application_AuthenticateRe
' 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!!!!!!!!!!!!!!
instead of source (src you wrote Scr="uc_shopping_cart.ascx ")
and it hasn't this attribute :-) good luck
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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\BajaSa lsa\BajaSa lsa.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</a sp:HyperLi nk>
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.OleDbDat aReader
Private DTRCategory As System.Data.OleDb.OleDbDat aReader
Private DB As New System.Data.OleDb.OleDbCon nection
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 .HtmlGener icControl
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.Debugg erStepThro ugh()> 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.QueryStri ng("catego ry"))
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.OleDbCon nection
Dim DA As System.Data.OleDb.OleDbDat aAdapter
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.OleDbDat aAdapter(S QL, 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. DataGridCo mmandEvent Args) 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\BajaSa
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</a
The page I'm trying to hyperlink to:
Public Class index
Inherits System.Web.UI.Page
Protected WithEvents lblCart As System.Web.UI.WebControls.
Private DTRProducts As System.Data.OleDb.OleDbDat
Private DTRCategory As System.Data.OleDb.OleDbDat
Private DB As New System.Data.OleDb.OleDbCon
Protected WithEvents HyperLink1 As System.Web.UI.WebControls.
Protected WithEvents lblCartStatus As System.Web.UI.WebControls.
Protected WithEvents DGrid As System.Web.UI.WebControls.
Protected WithEvents HyperLink2 As System.Web.UI.WebControls.
Protected WithEvents HyperLink3 As System.Web.UI.WebControls.
Protected WithEvents STRONG1 As System.Web.UI.HtmlControls
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.Debugg
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("
LoadData(Request.QueryStri
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.OleDbCon
Dim DA As System.Data.OleDb.OleDbDat
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.OleDbDat
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.
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("
Session("UserCart") = UserCart
End If
Catch ex As System.Exception
Response.Write(ex.Message)
End Try
End Sub
Private Sub DGrid_SelectedIndexChanged
End Sub
End Class
ASKER
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\BajaSa lsa\BajaSa lsa.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</a sp:HyperLi nk>
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.OleDbDat aReader
Private DTRCategory As System.Data.OleDb.OleDbDat aReader
Private DB As New System.Data.OleDb.OleDbCon nection
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 .HtmlGener icControl
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.Debugg erStepThro ugh()> 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.QueryStri ng("catego ry"))
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.OleDbCon nection
Dim DA As System.Data.OleDb.OleDbDat aAdapter
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.OleDbDat aAdapter(S QL, 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. DataGridCo mmandEvent Args) 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
I get this error: Could not find file 'c:\inetpub\wwwroot\BajaSa
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</a
The page I'm trying to hyperlink to:
Public Class index
Inherits System.Web.UI.Page
Protected WithEvents lblCart As System.Web.UI.WebControls.
Private DTRProducts As System.Data.OleDb.OleDbDat
Private DTRCategory As System.Data.OleDb.OleDbDat
Private DB As New System.Data.OleDb.OleDbCon
Protected WithEvents HyperLink1 As System.Web.UI.WebControls.
Protected WithEvents lblCartStatus As System.Web.UI.WebControls.
Protected WithEvents DGrid As System.Web.UI.WebControls.
Protected WithEvents HyperLink2 As System.Web.UI.WebControls.
Protected WithEvents HyperLink3 As System.Web.UI.WebControls.
Protected WithEvents STRONG1 As System.Web.UI.HtmlControls
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.Debugg
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("
LoadData(Request.QueryStri
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.OleDbCon
Dim DA As System.Data.OleDb.OleDbDat
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.OleDbDat
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.
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("
Session("UserCart") = UserCart
End If
Catch ex As System.Exception
Response.Write(ex.Message)
End Try
End Sub
Private Sub 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??
and also is IWAN-your computer name has access read and right to your db??