Solved

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

Posted on 2006-07-10
3
1,030 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

696 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