Open Popup window in xaf C#

1.1k views Asked by At

I want to force the user to select values from a popped up window if no value is provided for the relevant field when trying to save (for instance saving a contact) in xaf web application? How can this be achieved?

1

There are 1 answers

1
shamp00 On

With the XAF framework you can achieve most things, but it depends how much you want to fight with it.

The XAF way is to use the validation module and to add a RuleRequiredField to your property (documentation). Then when a user presses save an error message will appear and the relevant field will be focused. After the user has fixed the offending field, they can click save again. Not exactly what you describe but it works very well. Something like this:

   private string _Title;
   [RuleRequiredField("RuleID_TitleIsRequired", DefaultContexts.Save, "A title must be specified.")]
   public string Title {
      get { return _Title; }
      set { SetPropertyValue("Title", ref _Title, value); }
   }

Any reference field in edit mode can appear as a popup window. There are various alternatives for reference property editors all documented here and in your case you can control which type of editor appears (ASPxLookupFindEdit which is a popup window or ASPxLookupDropDownEdit which is a drop down) via the model.

If you are set on a popup appearing after pressing Save, then you would have to override the behaviour in the WebModificationsController. There is some documentation here. It would be a feasible change, but if you are not experienced with XAF I would recommend sticking with the validation rule.