Solved

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

Posted on 2006-07-10
3
1,021 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

867 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now