Solved

alter master page HTML in codebehind of a user control

Posted on 2013-11-29
1
302 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
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

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

Suggested Solutions

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

920 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

16 Experts available now in Live!

Get 1:1 Help Now