Override Controller Behavior
using DevExpress.ExpressApp.Web.SystemModule;
using MySolution.Module.BusinessObjects;
// ...
public partial class MyWebDetailViewController : WebDetailViewController {
public MyWebDetailViewController() {
InitializeComponent();
RegisterActions(components);
}
protected override void SaveAndClose(SimpleActionExecuteEventArgs e) {
View view = View;
base.SaveAndClose(e);
if ((view != null) && (((DetailView)view).ObjectTypeInfo.Type == typeof(Contact))) {
view.Close();
}
}
}
-
With this code, the SaveAndClose Action will close the current Detail View only if it displays a Contact object. You should always use the demonstrated approach to customize a built-in Controller behavior for a particular View or business class instead of changing the Controller's TargetObjectType, TargetViewType, TargetViewId and TargetViewNesting properties. Otherwise, you will lose the functionality of the inherited Controller in other Views.