Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8562907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:50:09+00:00 2026-06-11T16:50:09+00:00

Please see update far below for a briefer description I’m having a problem with

  • 0

Please see update far below for a briefer description

I’m having a problem with the Event based MVP approach. I have the following set up:

public class MeetingPresenter : IMeetingPresenter
{
     IViewMeeting;
     public MeetingPresenter(IViewMeeting view)
    {
        this.View = view;
        PopulateViewData();
        this.View.MeetingSavedClicked += OnMeetingSavedClicked;
    }

    public void PopulateViewData()
    {
         Imeeting meeting = service.GetMeeting();
         view.SetMeetingDate(meeting.date);
     }

    private void OnMeetingSavedClicked() 
    {
         service.SaveMeeting(view.GetMeeting());
     }
}


public interface IViewMeeting
{
     void SetMeetingDate(Datetime date);
     IMeeting GetMeeting();

     event Action MeetingSavedClicked;
}

and then View: (written in vb)

Partial Class MeetingPage
Inherits System.Web.UI.Page
Implements IViewMeeting
{

         Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

           If Not IsPostBack Then
               Presenter = New MeetingPresenter(Me)
           Else

          End If
       End Sub

       Private _presenter As IMeetingPresenter
       Public Property Presenter() As IMeetingPresenter
       Get
           Return _presenter
       End Get
       Set(ByVal value As IMeetingPresenter)
           _presenter = value
       End Set
      End Property

       Public Sub SetMeetingDate(ByVal date As Datetime) Implements IMeetingVisits.SetMeetingDate

           lblMeetingDate.Text = date.Date.ToString()
        End Sub
 }

       //Not implementing this fully - should get the idea
       public Function GetMeeting as IMeeting Implements IMeetingVisits.GetMeeting

       end function

       Event MeetingSavedClicked As Action Implements IViewMeeting.MeetingSavedClicked


       Public Sub btnSaveMeeting_Click(ByVal sender As Object, ByVal e As System.EventArgs)

           RaiseEvent MeetingSavedClicked()
        End Sub
  • Before continuing – I realise I can be taking out dependencies in the View, etc, and that any model should be View specific. *

The problem I’m having is with events. I am subscribing the the View interface events in my presenter. The view, on load, is creating a concrete version of this presenter, which in term causes the presenter to populate all of the views fields. So far so good.

The problem is that when the MeetingSavedClicked event is raised through btnSaveMeeting_Click, the corresponding subscribing methods in presenter are not fired. It is presumably because the presenter is no longer in memory, since state is not maintained after postback. I wasn’t sure if a subscription in presenter event would cause it to stay in memory in some way (I really don’t know much about custom events), but it seems this is not the case.

Is the only option then, to store the presenter in view state or session? Will this mean the event subscriptions will still exist and execute?

Apologies if this seems quite basic, but I’m a bit of a novice with events, MVP, etc.

UPDATE
Perhaps I can make this a little clearer:

My webform implements an interface which has an action event.

The webform creates a custom object that has a method subscribed to this interface event.

On postback, a click event is raised on webform (code behind), which in turn Raises the implemented interface event.

Now, the custom object is no longer in the state memory for the webform, as we are on a postback (and custom object not stored in session or viewstate).

Should my subscribed handlers still be out there and be able to catch this raised event? Or have they been ‘disposed’ by the time of the postback?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T16:50:11+00:00Added an answer on June 11, 2026 at 4:50 pm

    The page-object that is used in the postback is a completely new page-object. It is in no way connected to your old page-object. To solve your problem you have to recreate your presenter and you ahve to wire the events up, again.

    Technically your old page-object and presenter-object, and the eventhandlers between them might still be in memory if the garbage collector hasn’t collected them yet. But there are no references to those objects, and they will/might be collected in the next GC-run.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Update: Please see below; I have removed all abstraction and created a plain PHP
UPDATE: Please see the updates below, as I'm adding more information to the bottom
(Problem solved, please see the updates) I have some files that have incorrect filenames
Update - Please see update below. I'm attempting to improve the performance of our
* Solved, see Update below I have a class with the two properties listed
(Please see update at bottom) I've looked at dozens of questions and haven't been
How do we update a textbox on ticking checkboxes? Please see the following code,
Please see below code: thrust::device_vector<int>::iterator whereToBegin = copyListOfNgramCounteachdoc.begin(); end = thrust::unique_by_key(end.first, end.first + numUniqueNgrams,end.second);
Please see below: I tried using Absolute layout, but that's deprecated. I appreciate your
Please see the code snippet below : #include <iostream> using namespace std; int main()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.