Dave Noderer's Blog

August 2006 Entries

ASP.NET 2.0 - Accessing master page controls

Recently I needed to access a control in the master file of a page. Pretty simple but took a little investigation and experimentation.

I was looking for a control in the footer and in the actual application fetch contact information relavant to the current context.

If Me.Form.Parent IsNot Nothing Then
    Dim olbl As Label = Me.Form.Parent.FindControl(
"lblRegFooter")
     
'
    If olbl IsNot Nothing Then
        olbl.Text = "Set to what you want, will probably be something dynamically generated or fetched from a database!"
    End If
    '
End If