Solved

HowTo: Apply theme to master AND sub-pages (VS2010 Pro)

Posted on 2010-08-12
4
795 Views
Last Modified: 2012-05-10
Greetings I am brand spanking new to VS Studio 2010 and relatively new to ASP.Net, so be gentle in your reply.

Question: I am trying to set-up a theme which is viewable on all sub-pages. In previous versions of VS, I could simply add <pages theme="myTheme" /> to the web.config file. Now in VS 2010 the web.config has been "refactored" and I cannot add that code ....so...now what?

Please advise
sleeper
0
Comment
Question by:the_sleeper
  • 2
  • 2
4 Comments
 
LVL 1

Expert Comment

by:gouber
ID: 33420948
Assuming you are doing a web project and not a windows project, you can use a master page.  Create a Site.Master file liek the following.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>My web site</title>
</head>
<body>
    <asp:ContentPlaceHolder ID="MainContent" runat="server" />
</body>
</html>

Then on each page that you create add the master file like this ...
<%@ Page Title="" Language="C#" MasterPageFile="~/LocationOfFile/Site.Master" CodeBehind="Test.aspx.cs" Inherits="YourProj.Test" %>

<asp:Content ID="Resource1" ContentPlaceHolderID="MainContent" runat="server">

Note, you can have more than one content holder in your master file.  Good luck.
0
 
LVL 1

Expert Comment

by:gouber
ID: 33421012
On a side note, if you are doing a windows app, you can create a main form that has your layout.  Then based on what you want to show, show or hide a user control in a container.  I have used a ToolStripContainer in the past.  You can put your buttons at the top in a tool strip, then show and hide user controls based on the click.  To add a user control to the tool strip container use, ToolStripContainer1.ContentPanel.Controls.Add(yourUserControl);
0
 

Author Comment

by:the_sleeper
ID: 33421123
Greetings gouber,

1. Yes, I am building a web site. But my question is about how to Apply a THEME to the MasterPage suc that all pages that DERIVE from that MasterPage can automatically apply that theme.
2. In earlier versions of VS I could simply add the following (see code block):
3. This is not available (in the web.config file) in VS 2010, so
4. My question is how to do the equivalent of item #2 in VS2010.

Hope that make the question clearer.
sleeper
<!-- this was doable in earlier versions of Visual Studio, but I cannot do this in VS 2010 as the web.config has been refactored.

So how do I still accomplish this objective in vs 2010-->


<page theme="myTheme" />

Open in new window

0
 

Accepted Solution

by:
the_sleeper earned 0 total points
ID: 33429269
OK, I figured it out. Still uses <pages theme="myTheme" />  directive in the newly re-factored web.config.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question