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.

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 comment

Blog at WordPress.com.