Solved

alter master page HTML in codebehind of a user control

Posted on 2013-11-29
1
314 Views
Last Modified: 2013-12-04
I have a master page with the following tag
<section id="bannerSection">

Open in new window


I'd like to put a user control on some of these master pages which alter this HTML to:
<section id="bannerSection"  style="background: url(Libraries/banners/slide1.jpg) no-repeat center center; ">

Open in new window


I presume the first thing i need to do is put run at server on the html control on the master page
<section id="bannerSection" runat="server">

Open in new window



but what code do i need to put in the Usercontrol to search for this div and alter it with the style...
?????????

Its a bit more involved with a CMS and different bg images etc, so i've stripped the question back to its basic form
but if i can do exactly what i've said above, i can figure the rest out myself so it works in the CMS
0
Comment
Question by:websss
[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
1 Comment
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 39685305
You can access the control via the Pages reference to the Master, with something like:
HtmlGenericControl control = Page.Master.FindControl("wibble") as HtmlGenericControl;
control.Attributes.Add("style", "background-color:yellow;");

Open in new window

You'll need to include the System.Web.UI.HtmlControls namespace too.
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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

627 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