Skip to content

ModalView

Gerard Llort edited this page Oct 20, 2015 · 9 revisions

A ModalView (Cosmo.UI.ModalView) is a page created to be shown as a modal form.

A ModalView can be created using two methods:

Method 1

This way is for modal views which have a constant creation parameters.

For example, imagine a modal form to upload files to a document, which is shown in a PageView. In this view, we receive the parameters to show the document. We have all the information that we need to show the modal form (for example, the document identifier from database).

This scenario is the most easy to develop. In the main view (PageView), on InitPage event, we can declare the ModalView and then, add it to the modals collection in PageView:

public override void InitPage()
{
   int documentID = Parameters.GetInteger("objId");
   
   (...)

   UploadModal modal = new UploadModal(documentID);
   Modals.Add(modal);

   (...)
}

...and the modal declaration must have a similar apparence:

public class UploadModal : ModalView
{
   // Modal element unique identifier
   private const string DOM_ID = "upload-modal";

   public UploadModal(int objectId) : base(UploadModal.DOM_ID)
   {
      this.ObjectID = objectId;
   }

   public int ObjectID { get; set; }

   public override void InitPage()
   {
      ...

Method 2

This way is for modal views which have a creation parameters which depends on a variable values.

For example, imagine a modal form to show country information depending on a ComboBox control placen in a PageView. We need to pass the country selected by the user to the modal via POST or GET.

This scenario is a Little more complex tan the other, but easy. In the main (PageView), on InitPage event, we can declare the ModalView and then, add it to the modals collection in PageView:

public override void InitPage()
{
   int documentID = Parameters.GetInteger("objId");
   
   (...)

   UploadModal modal = new UploadModal(documentID);
   Modals.Add(modal);

   (...)
}
Clone this wiki locally