Get MasterPage Fields from ContentPage

Posted: September 24, 2010 in ASP.Net

You may need to access fields on a MasterPage from the ContentPage sometimes. In my situation I had to access a label control that held the phone number in the MasterPage and update the value of this from the ContentPage.

Code Behind (VB.Net)

Dim lmp_master As MasterPage = TryCast(Me.Master, MasterPage)
Dim lbl_phone_no_value As Label = TryCast(lmp_master.FindControl("lbl_phone_no"), Label)
lbl_phone_no.Text = "1234567890"

Leave a Reply

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

You are commenting using your 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 )

Google+ photo

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

Connecting to %s