Thomas’ Developer Blog

October 1, 2008

Finding control on master page from content page.

Filed under: Asp.Net Framework 2.0, HTML, javascript, vb.net — Tags: , , , , , , , — sanzon @ 11:16 pm

Well this is a quicky for you. To find an element on a master page it’s really simple just use:

Dim pagebody As HtmlGenericControl = CType(Master.FindControl(“pagebody”), HtmlGenericControl)
pagebody.Attributes.Add(“style”, “background-color:black;”)

Basically the key to this is Master.FindControl(“my control ID”) and you use CType to convert it, in this case to a basic HtmlGenericControl. This example is used for adding an attribute to the body tag in the master page. Great for javascript solutions like onscroll or any other mouse event.

Advertisements

2 Comments »

  1. This is a remarkable scandal. ,

    Comment by Kelvin63 — October 22, 2009 @ 11:26 am

  2. The information contained in this page is brilliant. ,

    Comment by Barbara29 — October 23, 2009 @ 10:31 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: