WebUserControl and Presenter

Topics: Web Client Software Factory, UIP Application Block discussion
May 31, 2007 at 12:08 PM
Hi All,

I try creating some WebUserControls. For each controls have own Presenter. Project is compiled. But when I try go to my page, which contains these controls, I have the following error:

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 23: if (!this.IsPostBack)
Line 24: {
Line 25: this._presenter.OnViewInitialized();
Line 26: }
Line 27: this._presenter.OnViewLoaded();
Source File: …\WebClientApplication2\WebSites\DevelopmentWebsite\Module1\WebUserControl.ascx.cs Line: 25

public partial class Module1_WebUserControl : System.Web.UI.UserControl, IView1
{
private View1Presenter _presenter;

protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this._presenter.OnViewInitialized();
}
this._presenter.OnViewLoaded();
}

CreateNew
public View1Presenter Presenter
{
set
{
this._presenter = value;
this._presenter.View = this;
}
}

public IList<Customer> Customers
{
set
{
CustomersDataSource.DataSource = value;
}
}
}

But this Presenter is working with Page. Wherein the problems?

Best regards...
Developer
May 31, 2007 at 2:23 PM
Hi Andrei,

Currently the CWAB is not building User Controls with ObjectBuilder, hence you don’t have Dependency Injection over them.

Nevertheless, you can extend Web Client Software Factory to solve this.

Take look at this thread: ObjectBuilder Customization For User Controls & Master Pages . In this thread you will found a solution.

Let me know if this helps,

Ezequiel Jadib
http://staff.southworks.net/blogs/ejadib
Jun 1, 2007 at 6:30 AM
Hi,

Thanks a lot! It's helps.

Best regards...