Accessing Master Page Control event from a child page


I was wondering if it is possible to access Master Page Control events from a child page. What I mean is, I have a button on the master page, I need to modify its onclick event on a particular child page, is there a way to do it? I know how to access the control attributes, i.e.: Dim Button as Button = CType(Master.FindControl("Button1"), Button), but I can't figure out how to accss its events.

Please help,

Many thanks,


11/29/2008 2:33:20 PM 13714 articles. 0 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 27
Get it on Google Play
Get it on Apple App Store

Got it...

Page load event of the content page:

        Dim mp As MasterPage = CType(Page.Master, MasterPage)
        RemoveHandler mp.Button.Click, AddressOf mp.Button_Click
        AddHandler mp.Button.Click, AddressOf Button_Click


a separate function

    Protected Sub Button_Click(ByVal sender As Object, ByVal e As System.EventArgs)
'what I needed to do.
    End Sub

and some changes in the master page:

changed Private to ovveridable

    Overridable Sub Button_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles Button.Click

'original code
    End Sub

and added this

    Public ReadOnly Property Button() As Button
            Return Button
        End Get
    End Property

Hope this will be useful to anyone...

11/29/2008 5:45:00 PM

Thanks for posting this, Alexi. It very much put me on the right track. I had a similar (but probably less complicated) situation, and I thought I’d post my findings as well. For me, all I had to do was find the MasterPage control on Page_Load of my Content page, and then add the handler like this:

Dim ddlFacility As DropDownList = Me.Master.FindControl("ddlFacility")
AddHandler ddlFacility.SelectedIndexChanged, AddressOf MyLocalRoutine
This way I was able to execute events for this one control on both the MasterPage and the ContentPage, and I didn't have to deal with any "WithEvents" or "Overridable" calls.

Thanks again!


12/4/2008 3:49:29 PM


Glad I could help. just for clarification, in my case I had to get rid of the code in the master page as it would have conflicted with new code I was loading on the content page, hence ovveriadble and removehandler lines.

with addhandler, i understand you just added lines to the existing code in the master page.



12/7/2008 8:12:54 AM

Web resources about - Accessing Master Page Control event from a child page -

Highest Percentage Of Opera Mini Users Accessing Facebook? Macau
If you were asked to guess which country had the highest percentage of users of Opera mobile Web browser Opera Mini users accessing Facebook ...

International Users Accessing Facebook Places Through US VPN Accounts
By using a virtual private network (VPN) hosted in the United States, Facebook users from around the world are accessing Facebook Places. The ...

What are some alternatives to Yodlee for accessing bank information?
Clay Loveless , Founder, Jexy. Co-founder, Mashery. Founder, Jexy. Co-founder, Mashery.

Cloud Console - Accessing files in cloud storage for iPad on the iTunes App Store
Get Cloud Console - Accessing files in cloud storage on the App Store. See screenshots and ratings, and read customer reviews.

Meryl Streep On Accessing The Characters Within - YouTube
Meryl Streep talks about the importance of an actors work representing their ability. CONNECT WITH AFI: ...

Student pleads guilty to accessing records about Frances Abbott design scholarship
The Sydney student who leaked information about a fashion school scholarship controversially awarded to the daughter of the Prime Minister has ...

Accessing a headline opinion
Accessing a headline opinion

Sharp increase in authorities accessing private data
Australian law enforcement and government agencies have sharply increased their access without warrant to vast quantities of private telephone ...

Former librarian charged with accessing student records of Frances Abbott
A former part-time librarian at a Sydney design school has been charged after she allegedly accessed student records of Prime Minister Tony Abbott's ...

Frances Abbott scholarship: Sydney woman pleads guilty to accessing Whitehouse Institute records on PM's ...
A Sydney woman who leaked the student records of Tony Abbott's daughter pleads guilty. A Sydney woman who leaked the student records of Prime ...

Resources last updated: 1/10/2016 7:14:54 PM