Last post Apr 28, 2020 06:23 PM by 0belix
Apr 28, 2020 12:06 PM|0belix|LINK
I have created a property on my masterpage
Public Property FillersInPage As New List(Of Filler)
This list needs to be updated from within a usercontrol that will be instanced multiple times inside a page that uses the masterpage mentioned above.
So, it will look something like this:
I've tried referencing the masterpage inside the userControl.ascx, so that i could later on use DirectCast to instance and access the FillersInPage property of the masterpage in order to update its contents, but i can't seem to be able to do so.
I'm using a Website project with vb.net.
Anyone got a clue on the correct way to do this, if there is one?
Apr 28, 2020 12:24 PM|mgebhard|LINK
The standard mechanism in Web Forms are events (delegates). The user control fires an event. The content page handles the event and throws another event. The master page handles the content page event. Essentially this creates a pipeline from the user
control to the content page then up to the master page.
You can also have the content page update the master page directly using a page directive. You still need a user control event handler in the content page. I prefer to use events as because events do not tightly couple the 3 classes. Although you need
to wire up the event which is pretty simple anyway.
Apr 28, 2020 06:23 PM|0belix|LINK
I ended up taking a different approach at my problem, controlling all from the page, instead of using the events as you suggested, but i'll keep them in mind the next time i approach a problem like this :)