Hi Imar, I have included the full code for Default.aspx both back (where the error is located) and front pages. The code is getting a bit long by the time we reach page 426 in the book, so I have added a selection from the 'Sub EventCalendar_DayRender()' procedure to home in on the offending line.
If I hover the mouse over the e.cell.cssclass I get a tip which reads "'cssClass' is not a member of 'System.Web.UI.WebControls.TableCell'" I think this another case where there is a failure of communication between the front and back pages which is possibly why it claims that cssclass is **not** a member.
Strange thing is if I delete this line the code runs without an error being notified (however I have lost the red 3 dot lines round the selected dates).
When I create pages in VS.NET I have been adding a new WebForm, naming it then typing the code (because I find I can appreciate what it is doing better than copying it in from another source) I edit it in the VS application user interface on screen (API) (need another screen dump for clarification)
I have used Notepad in the past, when working with ASP and InterDev6 but this required the new .asp file added from source into the project from where it would be written to the root directory, but not for VS.NET
I have to say that I rarely used the designer in InterDev preferring to write HTML or
VB in the script, into the code page, which in turn maybe why I have not appreciated the extent that VS.NET automatically writes code for the developer and why I have been experiencing difficulty linking the back page. If I write code in the front page without using the designer the "Protected WithEvents links" sometimes are not written.
Thanks again as always for your help,
Edward.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~
Selected code in Default.aspx back Page where error is located
Sub EventCalendar_DayRender(ByVal sender As Object, ByVal e As DayRenderEventArgs)
If Not Cache("DateList")(e.Day.Date) Is Nothing Then
e.Cell.ccsClass = "selecteddate" <-- code on the LHS of '=' is underlined
' The following line will exist in your code if you completed the exercisees
' at the end of the last chapter
e.Day.IsSelectable = True
Else
'This line of code is part of the solution to one of the exercises at the end
' of chapter 10
e.Day.IsSelectable = False
End If
End Sub
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~
Total code in Default.aspx Back Page
Public Class WebForm1
Inherits System.Web.UI.Page
Public DateList As New System.Collections.Hashtable
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents lnkTeams As System.Web.UI.WebControls.HyperLink
Protected WithEvents lnkPlayers As System.Web.UI.WebControls.HyperLink
Protected WithEvents lnkGames As System.Web.UI.WebControls.HyperLink
Protected WithEvents lnkResults As System.Web.UI.WebControls.HyperLink
Protected WithEvents EventCalendar As System.Web.UI.WebControls.Calendar
Protected WithEvents MatchesByDateList As System.Web.UI.WebControls.Repeater
Protected WithEvents pnlFixtureDetails As System.Web.UI.WebControls.Panel
Protected WithEvents lblRegister As System.Web.UI.WebControls.Label
Protected WithEvents txtEmailAddress As System.Web.UI.WebControls.TextBox
Protected WithEvents btnRegister As System.Web.UI.WebControls.Button
Protected WithEvents ValidEmail As System.Web.UI.WebControls.RegularExpressionValidat or
Protected WithEvents lnkMerchandise As System.Web.UI.WebControls.HyperLink
Protected WithEvents lnkChat As System.Web.UI.WebControls.HyperLink
Protected WithEvents ddlTheme As System.Web.UI.WebControls.DropDownList
Protected WithEvents btnApplyTheme As System.Web.UI.WebControls.Button
Protected WithEvents chkRememberStylePref As System.Web.UI.WebControls.CheckBox
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
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
If Not Page.IsPostBack Then
If Session("SelectedCss") Is Nothing Then
If Request.Cookies("PreferredCss") Is Nothing Then
Session("SelectedCss") = "WroxUnited.css"
Else
Session("SelectedCss") = Request.Cookies("Preferred.Css").Value
End If
End If
End If
' we need to run this each time the page is loaded, so that
' after a date is selected and the page is posted back, the
' active dates will still be highlighted.
If Cache("DateList") Is Nothing Then
Dim DateReader As System.Data.IDataReader
DateReader = Dates()
While DateReader.Read()
DateList(DateReader("Date")) = DateReader("Date")
End While
DateReader.Close()
Cache.Insert("DateList", DateList, Nothing, DateTime.Now.AddMinutes(1), _
Cache.NoSlidingExpiration)
'Response.Write("Added to cache")
'Else
'Response.Write("Already in chache - nothing added")
End If
If Not Request.Cookies("EmailRegister") Is Nothing Then
txtEmailAddress.Visible = False
lblRegister.Text = "You have registered for email updates"
btnRegister.Visible = False
End If
End Sub
Function Dates() As System.Data.IDataReader
Dim connectionString As String = _
ConfigurationSettings.AppSettings("ConnectionStrin g")
Dim dbConnection As System.Data.IDbConnection = _
New System.Data.OleDb.OleDbConnection(connectionString )
Dim queryString As String = _
"SELECT [Games].[Date], [Games].[GameID] FROM [Games]"
Dim dbCommand As System.Data.IDbCommand = _
New System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
dbConnection.Open()
Dim dataReader As System.Data.IDataReader = _
dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)
Return dataReader
End Function
Sub EventCalendar_DayRender(ByVal sender As Object, ByVal e As DayRenderEventArgs)
If Not Cache("DateList")(e.Day.Date) Is Nothing Then
e.Cell.ccsClass = "selecteddate"
' The following line will exist in your code if you completed the exercisees
' at the end of the last chapter
e.Day.IsSelectable = True
Else
'This line of code is part of the solution to one of the exercises at the end
' of chapter 10
e.Day.IsSelectable = False
End If
End Sub
Sub EventCalendar_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs)
pnlFixtureDetails.Visible = True
MatchesByDateList.DataSource = _
GamesBydate(EventCalendar.SelectedDate.ToShortDate String)
MatchesByDateList.DataBind()
End Sub
Function Venue(ByVal OpponentLocation As String, ByVal MatchVenue As Integer) As String
If MatchVenue = 1 Then
' match is at home
Return "Wroxville"
Else
Return OpponentLocation
End If
End Function
Function GamesByDate(ByVal [date] As Date) As System.Data.IDataReader
Dim connectionString As String = ConfigurationSettings.AppSettings("ConnectionStrin g")
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString )
Dim queryString As String = "SELECT [Teams].[TeamName], [Opponents].[OpponentName], [Games].[Location], [Oppon" & _
"ents].[OpponentLocation] FROM [Teams], [Opponents], [Games] WHERE (([Opponents]." & _
"[OpponentID] = [Games].[OpposingTeam]) AND ([Teams].[TeamID] = [Games].[WroxTeam" & _
"]) AND ([Games].[Date] = @Date))"
Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_date As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
dbParam_date.ParameterName = "@Date"
dbParam_date.Value = [date]
dbParam_date.DbType = System.Data.DbType.DateTime
dbCommand.Parameters.Add(dbParam_date)
dbConnection.Open()
Dim dataReader As System.Data.IDataReader = dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)
Return dataReader
End Function
Function CheckFanEmailAddress(ByVal fanEmail As String) As Boolean
Dim connectionString As String = _
ConfigurationSettings.AppSettings("connectionStrin g")
Dim dbConnection As System.Data.IDbConnection = _
New System.Data.OleDb.OleDbConnection(connectionString )
Dim queryString As String = _
"SELECT COUNT( [Fans].[FanEmail] ) FROM [Fans]" & _
"WHERE ([Fans].[FanEmail] = @FanEmail)"
Dim dbCommand As System.Data.IDbCommand = _
New System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_fanEmail As System.Data.IDbDataParameter = _
New System.Data.OleDb.OleDbParameter
dbParam_fanEmail.ParameterName = "@FanEmail"
dbParam_fanEmail.Value = fanEmail
dbParam_fanEmail.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_fanEmail)
Dim Result As Integer = 0
dbConnection.Open()
Try
Result = dbCommand.ExecuteScalar
Finally
dbConnection.Close()
End Try
If Result > 0 Then
Return True
Else
Return False
End If
End Function
Function AddNewFanEmail(ByVal fanEmail As String) As Integer
Dim connectionString As String = _
ConfigurationSettings.AppSettings("connectionStrin g")
Dim dbConnection As System.Data.IDbConnection = _
New System.Data.OleDb.OleDbConnection(connectionString )
Dim queryString As String = "INSERT INTO [Fans] ([FanEmail])" & _
"VALUES (@FanEmail)"
Dim dbCommand As System.Data.IDbCommand = _
New System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_fanEmail As System.Data.IDbDataParameter = _
New System.Data.OleDb.OleDbParameter
dbParam_fanEmail.ParameterName = "@FanEmail"
dbParam_fanEmail.Value = fanEmail
dbParam_fanEmail.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_fanEmail)
Dim rowsAffected As Integer = 0
dbConnection.Open()
Try
rowsAffected = dbCommand.ExecuteScalar
Finally
dbConnection.Close()
End Try
Return rowsAffected
End Function
Sub btnRegister_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRegister.Click
Dim FanEmail As String = txtEmailAddress.Text
' Check whether the email address is already registered
' If not, we need to register it by calling the AddNewFanEmail() method
If CheckFanEmailAddress(FanEmail) = False Then
AddNewFanEmail(FanEmail)
End If
' Email has been registered, so update the display and attempt to set a cookie
txtEmailAddress.Visible = False
lblRegister.Text = "You have successfully registered for email updates"
btnRegister.Visible = False
Dim EmailRegisterCookie As New HttpCookie("EmailRegister")
EmailRegisterCookie.Value = FanEmail
EmailRegisterCookie.Expires = Now.AddSeconds(20)
Response.Cookies.Add(EmailRegisterCookie)
End Sub
Sub btnApplyTheme_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnApplyTheme.Click
Session("SelectedCss") = ddlTheme.SelectedItem.Value
If chkRememberStylePref.Checked Then
Dim CssCookie As New HttpCookie("PreferredCss")
CssCookie.Value = ddlTheme.SelectedItem.Value
CssCookie.Expires = Now.AddSeconds(20)
Response.Cookies.Add(CssCookie)
End If
End Sub
End Class
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~
Total code in Default.aspx Front Page