Hi,
I have just completed the Try It Out Exercise on page 231. However, when I view the Default.aspx page in the browser I receive the following error;
Server Error in '/Site' Application.
Theme 'Dark Grey' cannot be found in the application or global theme directories.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Theme 'Dark Grey' cannot be found in the application or global theme directories.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): Theme 'Dark Grey' cannot be found in the application or global theme directories.]
System.Web.Compilation.ThemeDirectoryCompiler.GetT hemeBuildResultType(String themeName) +934
System.Web.Compilation.ThemeDirectoryCompiler.GetT hemeBuildResultType(HttpContext context, String themeName) +73
System.Web.UI.Page.InitializeThemes() +8871714
System.Web.UI.Page.PerformPreInit() +38
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +328
Here is the code for my Frontend.master.vb
Partial Class MasterPages_Frontend
Inherits System.Web.UI.MasterPage
Protected Sub ThemeList_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ThemeList.SelectedIndexChanged
Dim preferredTheme As HttpCookie = New HttpCookie("PreferredTheme")
preferredTheme.Expires = DateTime.Now.AddMonths(3)
preferredTheme.Value = ThemeList.SelectedValue
Response.Cookies.Add(preferredTheme)
Response.Redirect(Request.Url.ToString())
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim selectedTheme As String = Page.Theme
Dim preferredTheme As HttpCookie = Request.Cookies.Get("PreferredTheme")
If preferredTheme IsNot Nothing Then
selectedTheme = preferredTheme.Value
End If
If Not String.IsNullOrEmpty(selectedTheme) AndAlso ThemeList.Items.FindByValue(selectedTheme) IsNot Nothing Then
ThemeList.Items.FindByValue(selectedTheme).Selecte d = True
End If
End If
End Sub
End Class
Here is the code for my BasePage.vb
Public Class BasePage
Inherits System.Web.UI.Page
Private Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles Me.PreInit
Dim preferredTheme As HttpCookie = Request.Cookies.Get("PreferredTheme")
If preferredTheme IsNot Nothing Then
Page.Theme = preferredTheme.Value
End If
End Sub
Private Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
If Me.Title = "Untitled Page" Or String.IsNullOrEmpty(Me.Title) Then
Throw New Exception("Page title cannot be ""Untitled Page"" or an empty string.")
End If
End Sub
End Class
Here is the code for my web.config page
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<pages theme="Monochrome" styleSheetTheme="Monochrome"></pages>
<compilation debug="false" strict="false" explicit="true" targetFramework="4.0" />
</system.web>
</configuration>
Thank you very much in advance!
Cheers
John B