Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

alter master page HTML in codebehind of a user control

Posted on 2013-11-29
1
Medium Priority
?
318 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

721 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