Search This Blog

Friday, June 1, 2018

How to access and manipulate a custom ASP.NET user control from a Controller in a Module project


We have updated our How to: Show a Custom Data-Bound Control in an XAF View (ASP.NET) tutorial with more information on how to pass external data to custom Web user controls

Previously, our customers had the following difficulties with this task:

- In which project to create web user controls. By default, ASP.NET suggests doing this in the YourSolution.Web project. Adding an *.ASCX control into the YourSolutionName.Module.Web project led to errors.

- How to deal with circular references when attempting to reference the YourSolution.Web project from a Controller defined in the YourSolutionName.Module.Web project.
- How to pass an IObjectSpace, XafApplication or current View object to a custom user control.


A common way to resolve such a dependency (unrelated to XAF itself) is to define an interface within your class library (a XAF module project) and implement it by using your custom user control.


3 comments:

  1. Hi Dennis, the link doesn't work, FYI. Regards / Mert

    ReplyDelete
  2. To access and manipulate a custom ASP.NET HostMyCode user control from a controller in a Module project, expose the control's properties and methods via a service or interface, then use dependency injection to call and manipulate it in the controller.

    ReplyDelete