How to split code into separate frames/forms and load them into a DIV?

Hi,
I’m working on a project in TMS Web Core and I’d like to organize my code better.

At the moment I have a main form with a menu (Dashboard, Clients, Operations, …). Each section has quite a lot of code, and I don’t want everything inside the same form.

What I would like to achieve is:

Keep each section (for example "Clients") in a separate form or frame, with its own code and UI.

In the main form, I only have a

(or TWebHTMLDiv) that acts as a container.

When the user clicks a menu option, I want to load that form/frame into the container div, so that the code stays modular and separated.

In other words: I want my menu items to just switch which independent form (or frame) is displayed inside a placeholder on the main form, instead of coding everything in one big unit.

What would be the best way to do this in TMS Web Core? Use TWebFrame, dynamic forms, or some other approach? Any example or best practice would be greatly appreciated.

One possible approach is the technique demonstrated in the demo under folder Demo\Basics\Formhosting that shows how you can load a secondary form in a main form in the scope of another control. In the demo it is a TWebPanel but this could be as well a DIV in the main page.

Ok, I've seen the demo, and I've tried to apply it, but when I create the form using that div as a container, instead of rendering the content inside the div, it creates a new div below all the html code.

Did you use the exact same approach as in the FormHosting demo?
I.e. used something like:

frm := TSubForm1.CreateNew(HostPanel.ElementID, @AfterCreate);

If a problem persists, please isolate and provide a sample source app with which we can reproduce the problem.

1 Like

I've reviewed the code, and after searching, I realized I hadn't set up the new form; I wasn't implementing it correctly...
Thank you so much for the support.
It was very helpful and fast. :slight_smile:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.