css attach to control

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

HarryDeBoer
Ebase User
Posts: 118
Joined: Tue Oct 23, 2012 7:01 am
Location: The Netherlands

css attach to control

#1

Postby HarryDeBoer » Mon Jan 27, 2014 2:52 pm

Hi

I created an CSS, attached it to a template which is attached to a project. Now I try:

var msg_ctrl = controls.MSG_PW;
msg_ctrl.setCssClass('error');
if (fields.PASSW_CURRENT.value != 'test') msg_ctrl.addErrorMessage("Wrong!", true);

But the css style is not shown. I cleared the inline style, but still no luck. What am I missing. When I code the style inside the inline style dialog it is working correcttly.

.error {
color: #D8000C;
background-color: #FFBABA;
}

Am I missing something?
0 x
Kind regards,

Harry

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Mon Jan 27, 2014 5:04 pm

You should be able to use the errorMsgClass property on a Message Control like this, but I couldn't get it to work:

Code: Select all

msg_ctrl.errorMsgClass = "error";
However, it works if you set the properties individually like this and don't bother with a class:

Code: Select all

msg_ctrl.errorMessageStyle.textColor = "#D8D8D8"; 
msg_ctrl.errorMessageStyle.backgroundColor = "#FFBABA"; 
Regards
Jon
0 x

HarryDeBoer
Ebase User
Posts: 118
Joined: Tue Oct 23, 2012 7:01 am
Location: The Netherlands

#3

Postby HarryDeBoer » Tue Jan 28, 2014 7:31 am

Hi Jon,

is this a bug then? What I want to do is a centralized function to handle all messages where type is the classname:

function showMessage(msg,type,stop)
{
var msg_ctrl = controls.MSG;
msg_ctrl.setCssClass(type);
msg_ctrl.addErrorMessage(msg, stop);
}

It would be great if it should work as intended; that way all messagetypes (info, validation, succes, error, warning) could be handled. Of course as a workaround I could use an if or switch statment in the function and set the properties individually, but it isn't as 'nice'

The strange thing is that when I point the advanced properties of the styling assistant to all classes only ONE class (error) is shown no matter what value the type parameter of the above function is.
0 x
Kind regards,

Harry

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#4

Postby Jon » Tue Jan 28, 2014 10:49 am

Harry,

My reply yesterday was wrong - everything is working as intended.

You can't use the cssClass or setCssClass() method for a message control. This is because the message control doesn't output this class. See the documentation on message control for the details: Index > Controls > Message Control.

Instead you have to use the errorMsgClass or setErrorMsgClass() and warningMsgClass or setWarningClass(). These work fine. You can achieve what you want, but you will need to check the message type and set the appropriate property.

Regards
Jon
0 x

HarryDeBoer
Ebase User
Posts: 118
Joined: Tue Oct 23, 2012 7:01 am
Location: The Netherlands

#5

Postby HarryDeBoer » Tue Jan 28, 2014 11:33 am

Hi Jon,

Yes, got it now:

function showMessage(msg,type,stop)
{
var msg_ctrl = controls.MSGS;
msg_ctrl.setErrorMsgClass(type);
msg_ctrl.addErrorMessage(msg, stop);
}

Fantastic! Thanks.
0 x
Kind regards,

Harry


Who is online

Users browsing this forum: No registered users and 27 guests