top of page

Moji5 Knowledgebase

Displaying data in fancier ways using HTML

Problem

You need to dynamically assemble and display custom HTML data on your form.


You need to display a HTML table with two columns, with one of the columns displaying

the current system date and time, highlighted in red.



Solution

Setting up the sample:

1. Create a new form called "Sample HTML Display".

2. Create a label field called "Display".

















The solution:

1. Click the "Edit form behavior" link.

2. Click on "Create a new behavior" and click the "Action wizard" link.

3. Choose to "Create an action" and choose the "Static assignment" action.


4. Ensure that the "Display" field is selected and the property is set to "Value". Paste in the following HTML code:


<table border='1'><tr><td width='200px'>The date today is</td><td bgcolor='#FF0000' width='200px'>XXXX</td></tr></table>


5. Click the OK button and click save changes to close the popup window.

6. In the behavior editor window, click the "View code" button.


7. Manually replace the XXXX portion of the HTML string with " & Now & ".


The Now keyword is a VB.NET function that returns the current date and time. By keying in the doublequotes " & Now & ", you are terminating the HTML string and dynamically combining it with the system date and time. This is similar to writing something like: -

value = "My name is: " & PersonName


8. You should now see this in the behavior editor:


9. Save and close the behavior.

10. Publish your form.


Testing your solution:

1. Run the application & launch the form.

2. You will immediately notice a table with the background of the 2nd column set to red, and the system date and time showing in that column.



You can write HTML of any complexity. You can even use all the standard HTML tags such as <img>, and so on to insert images or flash objects into the field.


Combined with the dynamic nature of VB.NET, you can pull data from many different sources (including databases and so on) and assemble them into any HTML string that you wish.

Comments


bottom of page