Link to home
Start Free TrialLog in
Avatar of the_sleeper
the_sleeperFlag for United States of America

asked on

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

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
Avatar of gouber
gouber

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.
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);
Avatar of the_sleeper

ASKER

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

ASKER CERTIFIED SOLUTION
Avatar of the_sleeper
the_sleeper
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial