I am using DevExpress
Dashboard MVC Control
with my Project.
I need to subscribe to some of the events supported by the control from server side.Currently I'm subscribing to them in the MVC Controller
.
Is this the best place where I should place Event Handling
code? Do these events need to be unsubscribed to avoid memory leaks?
public class HomeController : Controller
{
public ActionResult Index(string mode)
{
//Some code commented
DashboardConfigurator.Default.CustomFilterExpression += MvcDashboard_CustomFilterExpression;
DashboardConfigurator.Default.CustomParameters += (sender, eventArgs) =>{
//Event specific code
};
return View();
}
public void MvcDashboard_CustomFilterExpression(object sender, CustomFilterExpressionWebEventArgs e)
{
// Event specific code
}
}
DevExpress Suggests to define in Application_Start method in the Global.asax.cs
We suggest specifying the default controller's settings in the Application_Start method in the Global.asax.cs file or in the RegisterService method in the DashboardConfig.cs file. The code snippet in the Step 9. Create a Dashboard Storage section of the Create an ASP.NET MVC Dashboard Application topic demonstrates this approach.