Solved

Programmatically changing Div style on Master Page based on displayed Content Page

Posted on 2006-07-10
3
1,027 Views
Last Modified: 2008-09-03
I have a div on my master page which needs to have its CSS style changed based on which content page it is displaying.  How can I do this?
0
Comment
Question by:psk1
3 Comments
 
LVL 27

Assisted Solution

by:Sammy
Sammy earned 250 total points
ID: 17078483
Run the div as server control and do something like this

If i = 0 Then
            Me.div1.Attributes.CssStyle.Clear() 'Clear Css Styles
            Me.div1.Attributes.CssStyle.Add("Class", "secondCssClass") 'add the css class attribute
        Else
            Me.div1.Attributes.CssStyle.Clear()
            Me.div1.Attributes.CssStyle.Add("Class", "firstCssClass")

        End If

of course this assumes you have 2 Css Classes named firstCssClass and secondCssClass

HTH
0
 
LVL 10

Accepted Solution

by:
aki4u earned 250 total points
ID: 17078524
System.Web.UI.HtmlControls.HtmlGenericControl divID =
            (System.Web.UI.HtmlControls.HtmlGenericControl)Master.FindControl("divID");
        divID.Attributes.Add("class","test");
0
 
LVL 2

Author Comment

by:psk1
ID: 17078773
Thanks!

My solution based on a hybrid of the above comments:

            Dim divID As System.Web.UI.HtmlControls.HtmlGenericControl = Me.Master.FindControl("divID")
            divID.Attributes.Clear()
            divID.Attributes.Add("class", "classname")
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

838 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