Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 21st, 2010, 02:27 PM
Registered User
 
Join Date: Mar 2010
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
Default StyleSheetTheme

In chapter 6 while configuring the page to use multiple themes, the theme did not display with the theme applied in the VWD. The author had us enter StyleSheetTheme="monochrome" to see the monochrome theme applied. After the ability to change themes was applied the styleSheetTheme="Monochrome" had to be remove because the DarkGrey theme was a combination of the two themes.

Is there another way to see the theme applied in the design view of the VWD?

So far this has been a great book.
 
Old June 21st, 2010, 05:29 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Not really with things set up as they are now; VWD has design support for the StyleSheetTheme only.

You could override the StyleSheetTheme programmatically instead of Theme as explained here: http://msdn.microsoft.com/en-us/library/tx35bd89.aspx

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
wildcatfan101 (June 21st, 2010)
 
Old September 8th, 2010, 05:39 PM
Registered User
 
Join Date: Sep 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Cool Chapter 6 - Missing images

Book is really awesome. I haven't have any issues until just now...

In chapter 6, I was able to incorporate the themes with no problem. They work just fine. However, for some reason I am unable to see the images associated with theme in the browser

I checked the url according to instructions listed on page 224 of the book and images still don't show up.

I have tried both cases scenarios to see if either one would work.

#MenuWrapper
{
background-image: url (Images/MenuBackground.jpg);
}

-------------

Also I tried the other case:

#MenuWrapper
{
background-image: url (/Images/MenuBackground.jpg);
}

-------------

Any thoughts anyone?

Thanks in advance,

Angie
 
Old September 9th, 2010, 02:57 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Angie,

Good to hear you like the book so much.

This CSS looks fine to me, so it must be something else. Is the class applied at all? Maybe you spelled it differently on the div? For example, like Menuwrapper instead MenuWrapper (lower case W)?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old September 9th, 2010, 11:15 AM
Registered User
 
Join Date: Sep 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Cool

Imar,

Thanks for your quick response. I did check the spelling and found no errors. In order to find a solution to the issue I was having, I also explore some other forums online. Luckily, I was able to find an easy fix. It appears I had a syntax error.

I replaced this:

#MenuWrapper
{
background-image: url (Images/MenuBackground.jpg);
}

-----------

with the following:

#MenuWrapper
{
background-image: url ('./Images/MenuBackground.jpg');
}

-----------

Not sure why the first option wouldn't give me an error. All I know is that the second option (listed above) did fix the issue

I am sharing the solution to the problem I was having in case someone else is having the same issue.

Like I said Imar your book is really AMAZING!. The reviews it has received on Amazon.com are all 5 stars. Thanks so much for explaining ASP.NET in such an easy way.
 
Old September 9th, 2010, 11:32 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Here's why it does or doesn't work. Images are relative *to the CSS file*. So this:

Images/MenuBackground.jpg

refers to an image located in the Images folder which is a sub folder of the folder that contains the CSS file. E.g.:

Code:
 
SomeFile.Css
- Images
  MyImage.jpg
But this:

./Images/MenuBackground.jpg

refers to an Images folder one level above the CSS file:

Code:
 
- Images
  MyImage.jpg
- Styles
  SomeFile.css
E.g. you go one level up (.. from Styles to the root for example) and then one level down again into the Images folder.

In the PlanetWrox theme, the Images folder is a sub folder of the Theme folder which contains the CSS file.

Hope this helps.

Quote:
Like I said Imar your book is really AMAZING!.
Thank you! Spread the word, spread the word ;-)

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old September 9th, 2010, 11:40 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Oh, just noticed you're using only a single dot.That shouldn't really make a difference.... ;-)

What does make a difference is a leading space. This works:

Code:
 
background-image: url(Images/SomeImage.png);
while this doesn't:
Code:
 
background-image: url (Images/SomeImage.png);
(Note the space after url).

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old September 11th, 2010, 06:47 AM
Authorized User
 
Join Date: Sep 2010
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default I can't make the changing theme by Code try it out

I am trying to follow 2 try it outs, the first in page 227, which enables the user to change the theme in drop down list, and the other is in page 231 which applies the theme by code.

I have copied the code and pasted it and did everything, but still didn't get any results, so I tried to follow up with the code to understand how it works, so we have 3 code blocks.. one on the drop down list selected index changed, and one on the page load (for the first try it out) and one for the page_preinit(for the second try it out), I understood how you made the cookie, but why do we check the (!page.ispostback) ??? I mean the page has its default theme in the web.config when it's not posted back so we already know what is its theme. and I didn't understand what these lines do :
if (preferredTheme != null)
{
selectedTheme = preferredTheme.Value;
}
if (!string.IsNullOrEmpty(selectedTheme) &&
ThemeList.Items.FindByValue(selectedTheme) != null)
{
ThemeList.Items.FindByValue(selectedTheme).Selecte d = true;
}
}


I thought we can just capture the value from the drop down list, save it in cookie, and then and then call the (Response.Redirect(Request.Url.ToString());) so we can capture the page_preinit again and apply the theme, why do we have to do code in the page_load, and what does it do?


Thanks a lot. I have been going in the first 5 chapter without any issues, but this one seems like tough one :) great book
 
Old September 11th, 2010, 06:59 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

(When you post code, can you please use the Code button on the toolbar rather than a tiny, red font? Makes things a bit easier to read.)

I am not sure I understand what you don't understand, so I'll explain some of it, and then let you ask follow up questions.

The code in Page_Load preselects the correct item in the drop-down list. If you choose DarkGrey, the selection is stored in a cookie, the user is redirected and then the theme is applied by PreInit in the BasePage class. To show the user that DarkGrey is active and that they can now switch to Monochrome, it's important to preselect DarkGrey in the DropDownList (otherwise, the list would default to the first item which is Monochrome). That's what this code does:

Code:
 
if (!string.IsNullOrEmpty(selectedTheme) && 
     ThemeList.Items.FindByValue (selectedTheme) != null)
{
  ThemeList.Items.FindByValue(selectedTheme).Selected = true;
}
This reads as:

- If there is a selected theme and the name of the selected theme appears as an item in the list then
- preselect the item in the list

Does your code work? If not, does your test page inherit BasePage so the theme is applied in the PreInit method?

Quote:
great book
Thank you.

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old September 11th, 2010, 07:13 AM
Authorized User
 
Join Date: Sep 2010
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default Replu

Doesn't the Enable view state on the drop down list preserve the current selection? do we have to write the code to preserve the user's selection?





Similar Threads
Thread Thread Starter Forum Replies Last Post
StyleSheetTheme in master page anujrathi ASP.NET 2.0 Professional 0 December 8th, 2006 04:03 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.