PC SOFT

PROFESSIONAL NEWSGROUPS
WINDEVWEBDEV and WINDEV Mobile

Home → WEBDEV 2024 → [controls] ID attribute value and custom attributes
[controls] ID attribute value and custom attributes
Started by EKoster, Apr., 07 2021 8:06 PM - 2 replies
Registered member
16 messages
Posted on April, 07 2021 - 8:06 PM
I can't seem to find the way to set the 'ID' attribute of a control you place on a page. I'm looking for setting the 'id' attribute of the html element (e.g. the field) with a specific value. It seems the current value is autogenerated. In extension to this question, I'm seeking how to add custom attributes to the control. Standard you have 'class', 'style', 'id' and so on, but I would like to add custom ones, in a similar way as you add classes to the controls. The use case for this is e.g. testing the application with something like 'jest' or a different test framework. You can use a query selector, but if the code is generated this is not the most efficient way. With a populated 'ID' and custom attributes you can do this directly being sure you have the correct control the fastest way possible.
Posted on April, 07 2021 - 9:16 PM
regarding the id, there is an option alowing to remove the automatic name generation for JS. Instead, it's the name of the field as defined in the webdev editor that is used (careful what you use in that case)...

That option is rarely used and is therefore well hidden:
THe option is where you define the html standard (either at the project level or at the page level, in the advanced tab).

Just to the RIGHT of the html option, there is a "..." button. when you clik it, you have extra options, including one called "compress alias and javascript procedure names"

If you uncheck it, you have your control names as designed in the editor.

as for the second part of your question, I'm not sure, but IF it is possible, it's going to be in the advanced tab of the control itself, you can add html code and add values in the class part of the control... Not sure if that will match your request, but you can try
Registered member
16 messages
Posted on April, 08 2021 - 7:22 AM
Thanks for the reply. I think I can find it. A shame it's so hidden.