Change page style client side

Like on http://www.yahoo.com/ I want to have different themes on my site. With a single mouseclick a user should be able to alter the page layout (without posting back).
Therefore I want to change the class of certain divs on my page. But the id's of these divs are different on all pages.
e.g. on the friends  page they are:

<div id="friends" class="layout_red"></div>
<div id="overview" class="layout_red"></div>

etc. I dont want to have javascript that differs on each page.

What I want is: a cookie that determines which color the user has selected, e.g. in cookie: 'orange'
Then with unobtrusive javascript replace all classes for the divs that have a class with "layout_" in their name and replace that with "layout_orange".

Would that be the quickest/advised way to go?





please mark answers as 'Answered' and post back solutions when you figure stuff out that isnt in the post already.
0
Peter
3/6/2008 9:44:59 AM
asp.net.client-side 24353 articles. 1 followers. Follow

5 Replies
706 Views

Similar Articles

[PageSpeed] 0

Hi,

I would advice you to use external css files. Name the file as your theme name, like red.css. When a user want an other theme, you change the reference of to that css file, like red.css -> blue.css. In this case you don't have to change all the id's and classes.


Please remember to 'Mark as Answer' if this post answered your question!
0
ShadowDanser
3/6/2008 11:22:29 AM

You should use Asp.net themes for this. The themes are made for this purpose only

http://www.vikramlakhotia.com/Dynamically_changing_themes_and_applying_styles_in_aspnet_20.aspx


Vikram
www.vikramlakhotia.com


Please mark the answer if it helped you
0
vik20000in
3/6/2008 11:25:32 AM
@ShadowDanser:

How would you change the included stylesheet with javascript then? And if I change it, will it be visible without postback?

Thanks!

please mark answers as 'Answered' and post back solutions when you figure stuff out that isnt in the post already.
0
Peter
3/6/2008 12:12:27 PM

I don't know if this is possible without postback.

Here is a link with postback:
http://www.codeproject.com/KB/aspnet/dynamicThemes.aspx

Here is a link without postback (but not with external css files, if i'm right):
http://developer.apple.com/internet/webcontent/styles.html

Hope this helps!


Please remember to 'Mark as Answer' if this post answered your question!
0
ShadowDanser
3/6/2008 1:41:39 PM

document.getElementById('DivID').className = 'NewClassName';


When you ask a question, remember to click "mark as answered" when you get a reply which answers your question.


My latest ASP.NET AJAX blog entries.
0
DisturbedBuddha
3/6/2008 3:30:27 PM
Reply:

Similar Artilces:

server side or client side page?
a page that contain a validation control and starting a storeProcedures when the user click on a button --is considered as a client side page or as a server side page?it seems to me that in asp.net everthing is server side, where are the client side pages?thanks The sp is server side, but the validation can be on or the other, depending on how it's coded.ASP.Net has it's validations, so it's server side when using them.But you can also make validations via JavaScript, so that would be client side.Zath but the validation controls (like RequiredFiledValidator) is a client side va...

List of client side function of extenders and controls for client side
Hello All,I am using AJAX control toolkit for my current project. Now I need to find out what client side functions I can call on an extender. Lets say I am using a PopControlExtender. Now I want to show the popup from a JS funtions.If I can do a guess then it would be something like this$find('ppce').show();From where I can find what client side functions I can call on those extensders. This is really a frusterating thing. I learn about extenders only from Learn tutorials, no help here and there. Can anybody please tell me where are documentations about all the extenders in the tool...

Changing Server-Side Control Properties by Client-Side
Hi, I have 4 server side button control. These are for choices of a competition website(A,B,C,D) and I have 1 client side button control named "Changer" on the same page. When I click the Changer I want it to disable A, if it is disabled I want it to disable B... The main question in this topic is "How can I change properties of a server-side control by client-side" My javascript side is not very well. How can I do this? Please help me. I got it guys. Thank You very much.. Hi, Here is the javascript for enable and disable two server side buttons with id Button1 and Butt...

Validation Controls in .NET ( Client side or server side?)
 i have a very basic question. We have all these validation controls in asp.net ( required field, range validator and others)..my question is the required field validator is a server side control. So does that mean that it does a post back?..is it client side or server side control  The only controls that post back are buttons and other inputs where you set AutoPostback="True", such as a dropdownlist or a textbox.  Another way of posting back is using an UpdatePanel and placing a trigger in it for a specified control and/or event. All controls are considered clien...

Jscript, moving from client-side to server-side (.NET)
Hey all I’m working translating a web-app written in client-side Jscript to run on the server-side as JScript.NET. Without needing to get too specific, I am using Jscript because the original page aggregated raw data to produce statistical results (this was done dynamically based on user 'sort-by' options). The final output is an html report that can be emailed. Because this is currently being done on the client side, as the raw data grows the load-time grows as well (to the point that has almost become unusable). I’m posting here to see if anyone has any experi...

Client side changes not reflected in page!
Well, I found exactly where the problem lies:When the control that changes value is a web control!Try yourselves the following code:page:   <%@ Page Language="VB" AutoEventWireup="false" CodeFile="test2.aspx.vb" Inherits="test2" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:label ID="lblTotalQuantity" EnableViewState="true" runat="server" BackColor=...

Changing client side cookies in .NET
I have a few cookies in my applicaiton which are created using javascript. Now I can read the cookies no problem. I can create the cookies in .NET and read them in javascript no problem. If the cookie is created in .NET i can modify it's value in .NET no problem. If the cookie is create in javascript I can modify it's value in javascript no problem. What I can't do is change the value of a cookie created in javascript using .NET. I have tried every permutation of Cookies.Add, Cookies.Set, Cookies.Remove using both the response and request objects. I can debug the code and see ...

Client side changes not reflected in page
Hi everyone! I have a hidden input field in a form which I change in some occasions on the client using javascript, but when I use "view source" I can't see these changes reflected on the page! Does anyone know what I should do in order for the page to know the change? (Tried with enableviewstate=false, true, whatever, didn't work) I would like to have the change reflected in the page without doing a postback! Is this possible? Thanks in advance! ok from this question: " I would like to have the change reflected in the page without doing a postback! Is this possible?' ...

When to use client side varidation and server side varidation in .net?
In .net or classic web application we can varidate user data either on client isde or server side. How to select which side varidate to be used? Thanks! Generally, I use both client and server validation. I make sure the input is in the correct format and reasonably valid on the client, then I verify the data on the server. The extent of validation also depends on the type of data that I need to validate.Here are a few references:Validating ASP.NET Server ControlsIntroduction to Validating User Input in Web FormsClient-Side Validation for ASP.NET Server ControlsSecurity Checklist...

Restrict Page Set Up changes at client side
Hi, My application consists of many ASPX Report pages. Our client wants to restrict users from changing the page set up( i.e.Margins, header, footer etc) as uniformity in reports will get hindered. I know one way to deal with this issue is through java script as the code written here would effect all the end users unlike the codes written in the aspx code behind files that will have impact only on the server. I have tried using ActiveX in scripts, but i am not very comfortable with it. I would be very thankful if anyone could come up with a solution for this issue. Thanks, V.M.Manish...

How to detect page content has been changed from client side?
Assuming I have a page with several textbox and dropdownlist controls. When any of content changed, a extra textbox becomes mandantory required and need to input the given string. If nothing changed, this textbox is optional. I am using VAM TextboxRequiredValidator to validate the textbox. This validator will be enable if contents has changes and disable if no changes.how to implement the javascript?Thanks, Have you considered asking VAM support?  This sounds like something the product should already do.Peter BrunoneMS MVP, ASP.NETFounder, EasyListBox.comDo the impossible, and go home...

Call server-side page function from client-side button click
I have an existing ASP application that I am migrating to ASP.net. In the ASP app I was using the Microsoft.XMLHTTP on a the client-side of a ASP page to retrieve data from another asp page using the Microsoft.XMLDOM object. The client page passes 3 tags columns, table and Criteria. The receiving page builds the SQL statement executes the query and returns the row with all the column data. I am trying to convert it over to ASP.NET and I am getting errors on the xmlDOM.Load(Request.InputStream) on DLookup.aspx, the code is listed below. Someone suggested to use System.Net HTTP classes su...

communication between client side(java script) and server side in .net project
I have a question which is, when building a .net project, we are able to use server side code and client side code(java script). How do they communicate? Thanks Client Side coding works with the WebBrowser. So when ever you write client side code you have to keep browser compatability in your mind and you have to code. Server Side code works with Web Server (IIS) and it's ASPNET ISAPI's. The won't directly communicate with each other. But using AJAX you can all server side code from Client Side! Example article on Ajax@ http://www.devarticles.com/index2.php?option=content&task=...

How to write data to a file in client side using javascript or someother client side scripting language.
Hi, I would like to know how to write a data to a client side file using javascript or someother client side scripting language. The file type expected is ini file. txt file would also be appreciable. Thanks in advance.   If the site is a trusted and you are running IE then you could try http://www.w3schools.com/asp/asp_ref_filesystem.asp The Old Sewing FactoryThat twitter nonsense. You can write to the server, but not to the client's machine.  Being able to do so would be a huge security breach.When you ask a question, remember to click "mark as answered"...

Web resources about - Change page style client side - asp.net.client-side

Change Congress - Wikipedia, the free encyclopedia
Change Congress is an American organization that aims to end perceived corruption in the United States Congress by reducing what it considers ...

James Ackerman tribute: Calls for Sunshine Coast stadium name change
Queensland Senator Glenn Lazarus and former Wallabies coach John Connolly have called on the Sunshine Coast Council to rename its stadium to ...

Why I Might Change My Name to 'Mom! You're So Weird'
Full Image: "Mom, you're so weird" is a phrase I hear daily out of my 17-year-old daughter. Unfortunately, I do not agree with her at all. I ...

How You Need To Change Your Sales Approach In a Digital World
This is going to be a succinct one, but it’s apparently a very difficult transition for a lot of organizations and individuals to make. Today, ...

NYU Study: Economics Of Climate Change Is A No-Brainer
As shown in numerous polls, most people in the US and elsewhere are concerned about the ecological effects of anthropogenic climate change. However, ...

How a 45,000-year-old mammoth carcass might change human history
Scientists unearthed evidence, in the form of a hunted mammoth, that humans were living remarkably far North in Siberia thousands of years earlier ...

Jeb Bush has a radical strategy to change Tim Cook’s mind on encryption
... for its decision to keep customer data private, but Apple fanboy Jeb Bush revealed he has a radical strategy that will get Tim Cook to change ...

If Kidnapping Sailors Won’t Change The Administration’s Course With Iran, What Will?
If Kidnapping Sailors Won’t Change The Administration’s Course With Iran, What Will?

Open thread for night owls: A new climate change disaster looms in northern Canada
James Wilt at Vice writes— There Is a New Climate Change Disaster Looming in Northern Canada : Of all the climate change issues that have been ...

Mélanie Laurent’s Climate Change Doc ‘Tomorrow’ Surges At French Box Office
Co-helmed by Inglourious Basterds ‘ and Now You See Me ‘s Mélanie Laurent , environmental documentary Tomorrow continues to stir up the French ...

Resources last updated: 1/16/2016 5:52:12 PM