How can I know the length of a content of a WebLabel

Hi all,

I need to display a single sentence on a webpage which is compiled at run time based on some logic or user selections. The outputs can be:

I have a beautiful cat.
My cat is very naughty.
Tom likes beautiful things.

“Beautiful”, “cat”, “naughty” are keywords for example. I would like those keywords to be coloured blue and underlined and can be clicked so that further relevant information can be displayed. How can I do this?


Here is a method that will let you place any kind of HTML within a label.

Public Sub HTMLText(extends Lbl as WebLabel, assigns URLTxt as string) Lbl.ExecuteJavaScript("document.getElementById('"+lbl.controlid+"').getElementsByTagName('p')[0].innerHTML='"+URLTxt+"';") End Sub

It must be placed on a module. Also, make sure at least one character is in the label at design time. For instance just a dot : “.”.

Here is an example of code that will make cat a link, and bold :

Label1.HTMLText="My <a href=""""><b>cat</b></a> is very naughty."

Note the double double quotes surrounding the URL.

You got to learn how to create HTML to obtain what you want. This is a good resource :

You can also use an HTML editor to compose your content, such as Kompozer.

Didn’t a recent IDE update make it so you can use HTML in a label field without workarounds?

Yes. Wrap it with <raw>YourHTML</raw> for WebLabel and quite a few others.

Well, so I did not notice.

Don’t worry, we all know which update I didn’t notice :wink:

At any rate, Tony has an answer.

Thanks all. It works.