CodeVerge.Net Beta
Login Idy
Register Password
  Forgot?
Explore    Item Entry    Members   
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML





Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 3/17/2008 4:42:40 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 4 Views: 8 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
5 Items, 1 Pages 1 |< << Go >> >|
MDCragg
Asp.Net User
Switching Master Page CSS Theme Programmatically3/17/2008 4:42:40 PM

0/0

How do I switch a master page's CSS page programmatically during form load?  I have tried the following but neither works:

Me.Page.StyleSheetTheme = "~/Master_001.css"

Me.Page.Header.Attributes = "~/Master_001.css"

 

Does anybody know how to do this?

 

Thanks in advance...MDCragg

lakkris
Asp.Net User
Re: Switching Master Page CSS Theme Programmatically3/17/2008 4:52:22 PM

0/0

Did you try the putting the code in Pre Init?

MDCragg
Asp.Net User
Re: Switching Master Page CSS Theme Programmatically3/17/2008 8:05:07 PM

0/0

Yes.  I just tried the following (each line except the last one is commented out...I didn't comment out each line as I was trying them though):

    Protected Sub PreInit(ByVal sender As Object, ByVal e As System.EventArgs)
        
            'Me.Attributes.Add("Background-image", "url(~/Images/WatchList_StopWatch.jpg)")
            'Me.Attributes.Item("background-image") = "~/Images/WatchList_StopWatch.jpg"
            'Me.Attributes("background-image") = "url(~/Images/WatchList_StopWatch.jpg) no-repeat;"
            'Me.Attributes.Add("Background-image", "url(/Images/WatchList_StopWatch.jpg)")
            'Me.Attributes.Item("background-image") = "/Images/WatchList_StopWatch.jpg"
            Me.Attributes("background-image") = "url(/Images/WatchList_StopWatch.jpg) no-repeat;"

    End Sub
 
lakkris
Asp.Net User
Re: Switching Master Page CSS Theme Programmatically3/17/2008 8:33:27 PM

0/0

Below is the code in C# which works fine for chaning the themes programmatically. 

protected override void Page_PreInit(object sender, EventArgs e)

{

           base.Page_PreInit(sender, e);

           MasterPage m = Master;

          if (Page.IsPostBack)

          {

                     if (Request != null && Request.Form["hdPageMode"] != null)

                        {

                                     if (Request.Form["hdPageMode"].ToString().Equals("Edit"))

                                               this.Theme = "DefaultTheme";

                                      else if (Request.Form["hdPageMode"].ToString().Equals("View"))

                                                this.Theme = "PrinceSkin";

                        }

          }

          else

          {

                      if (this.PageMode == PageActionType.View)

                                 this.Theme = "PrinceSkin";

                       else

                                 this.Theme = "DefaultTheme";

            }

}

Dave Sussman
Asp.Net User
Re: Switching Master Page CSS Theme Programmatically3/17/2008 11:18:36 PM

0/0

If you're using themes then download http://ipona.com/temp/ThemesVB.zip; this is a sample project that shows how to dynamically change both the theme and the master page depending upon user settings (it uses the profile). The Theme architecture is quite good for this even if you're not actually uses skin files; you can just create the theme folder and place the CSS files in it and changing the theme will automatically load the CSS file. I do have a purer CSS solution somewhere that doesn't use themes, but does much the same thing, switching out the CSS files; let me know and I'll try and find it.

d

5 Items, 1 Pages 1 |< << Go >> >|



Search This Site:


Meet Our Sponsors:



Other Resources:

External Post Office shows up as No Address in GWmonitor - novell ... External Post Office shows up as No Address in GWmonitor, > ROOT > NEWSGROUP > Novell ... switching master page css theme programmatically. All Times Are GMT ...
How to delete NetWare Licenses - novell.support.open-enterprise-server ... How to delete NetWare Licenses, > ROOT > NEWSGROUP > Novell Forums > novell.support. ... switching master page css theme programmatically. All Times Are GMT ...
CSS Problem with Menu in Master Page - ASP.NET Forums ... skin programmatically, CSS cascade Style sheet, asp.net 2.0 themes skins images, ... switch (Convert.ToString(this.Parent)) { case "ASP.default_aspx" ...
Specifying the Master Page Programmatically : The Official Microsoft ... A Theme is a collection of images, CSS files, and style-related Web control ... (Switch to Visual C# tutorials) Master Pages Tutorials Start Page. Introduction ...
Feedback: No way to add CSS files to Content pages when using master pages ... stylesheets programmatically using the following code on the content page where ... 3) create a content page. 4) switch to code view ...
Style Sheets in SharePoint Designer - ThemesWiki 2.9 Attaching Our StyleSheet to Our Master Page. 3 Summary. 4 Additional References ... We are now equipped to create new pages that follow a consistent theme. ...
Walkthrough: Creating User-Selectable Themes Creating an ASP.NET master page that uses a theme. ... To select different themes. Switch to the Home.aspx page, and then press CTRL+F5. ...
Inside Microsoft: Styling a Site using Themes ... described, including master pages, themes, and skins. ... display and layout of a page using themes, css and skin files without affecting the content. ...
Header image change per user - ASP.NET Forums ... Forums " General ASP.NET " Master Pages, Themes and Navigation Controls " Header ... I am using master pages and CSS. Thank you. Re: Header image change per user ...
Inside Microsoft: Structuring an ASP.NET 2.0 Site using Master Pages ... ... 2.0, asp.net 2.0, master pages, skins, themes -> Digg -> Reddit -> Del.icio.us ... property to the master page, which you can use programmatically to alter the ...


 
All Times Are GMT