简体   繁体   中英

Open Popup window in xaf C#

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM