Hi Brian, thanks for your response to my topic. Just when I think I am getting used to the way Visual Studio works it whacks me! I have been adding the Navigation Bar to my copy project of WroxUnited from the book 'Beginning ASP.NET 1.1' Pages 451 to 455, there is evidently a big difference between the way VS works from that of Web Matrix, while script is allowed code is normally added to a back page. Controls coding added to the back page has a link to the front page via lines found in the '#Region " Web Form Designer Generated Code "' section, these lines are normally written by VS at the time when Controls are added in the design view of the front page. If code is written in the HTML view of the front page or in the back page the above link lines are not added. In this instance when the NavBar.ascx file was coded the code was copied in from Default.aspx, in the back page of NavBar.ascx there was no location for the Control link code lines ('#Region " Web Form Designer Generated Code "') so I was in a quandry what to do to make the link and set the Control working.
Today when I received your reply, I opened the project to copy code into this responce to find the error reported different to that seen when working with the project, VS had in fact added the missing code, I have corrected the revised error and the project is working and I am back on track.
The back page code is as follows:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
Public Class Navbar
Inherits System.Web.UI.UserControl
#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 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 <-- This is the link that was reported missing in the initial effort. However this whole section (Region) had to be added by VS!
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
'Put user code to initialize the page here
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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
Many Thanks Brian for your response and interest.
Edward.
|