user2075599
user2075599

Reputation:

DevExpress XAF how to add a control to popup window of an action

I am having an extremely difficult time trying to figure out how to do what it seems like should be a simple thing within a DevExpress XAF application.

I have figured out how to add a custom action item to the top of a detail view of a business object. All I need to do is to display a popup window that contains a DevExpress Web UI control (ASPxUploadControl, but it could be any control, even a simple ASPxButton). This does not need to be platform-agnostic, it only needs to work in the Web UI app and can be implemented in the Web module and Web UI projects.

None of the DevExpress documentation seems to tie these couple of simple things together, and I can't figure it out. DevExpress support has not been very helpful either - to be clear, they have tried to help me but it seems like I can't get them to actually understand my exact scenario (based on the documentation they point me to, which seems to be way more complex than what I am trying to do).

Has anyone else implemented what i am after within DevExpress XAF? Can anyone with DevExpress XAF experience give me some tips on how to accomplish this?

Upvotes: 0

Views: 4756

Answers (2)

user2075599
user2075599

Reputation:

Also, I'm not using the FileAttachmentBase stuff, just handling the ASPxUploadControl's FilesUploadCompleted event to do manual writes to an Attachments table in the database that only stores the filename and filesystemlocation of uploaded files (and ASPxUploadControl stores files in the filesystem rather than in the database like FileAttachmentBase anyway). After a couple of days of banging on this I have almost gotten it figured out. Once I do I am going to post a youtube video so everyone can see exactly how this is done - with special emphasis on just how to plop any old DevExpress ASP.NET Webforms UI control into the custom action's custom popup window, and how to handle the UI control's events (like for the ASPxUploadControl, the FilesUploadCompleted event). The technical specifics are too verbose to post here.

Upvotes: 0

shamp00
shamp00

Reputation: 11326

You need to follow the tutorial here. In that example the popup window shows the properties of the Note object. You need an object with a property for your file upload. (Make sure you've added the File Attachments module).

So create an XPO object (or an EF object if you prefer) similar to the one described in the documentation for File Attachments like this:

[NonPersistent]
public class Resume : BaseObject {
   public Resume(Session session) : base(session) {}

   private FileData file;
   [Aggregated, ExpandObjectMembers(ExpandObjectMembers.Never)]
   public FileData File {
      get { return file; }
      set {
         SetPropertyValue("File", ref file, value);
      }
   }
}

Now follow the popup tutorial, but instead of Note, use Resume.

Notice that Resume is marked [NonPersistent], so it will not save it to the database, but you can get the contents in the Execute event. (Of course, if you would prefer to save the attachment to the database instead, use [DefaultClassOptions] as in the example for Note).

One more thing - make sure that the popup is opened in edit mode rather than view mode, otherwise the buttons for uploading will not appear.

Upvotes: 0

Related Questions