Can Ninject inject a class and make it reference the target class as a back reference?

537 Views Asked by At

I want to inject a presenter into my webform class. While doing so I would like the injected presenter to contain a reference to the view it is being injected into. Inject a class with a reference to the class it is injected into. Is it possible to do this with Ninject? When injecting into a webforms class, is the injection performed before the constructor is executed? Should I rather just inject the presenter and use the constructor to pass the view?

1

There are 1 best solutions below

2
On BEST ANSWER

For webforms this is not possible because the form is not created by ninject. You have to pass it manually to the presenter.

I think the solution is to use MVC there you have support for your problem form the framework. Webforms and MVC can be mixed. You can create new pages with MVC and still use the old webform ones. Whenyou have to change a webforms page then you better refactor it to MVC befor the change.