How to show error message on salesforce site?

You can use the property to show show error message on site. Below is an example which is self explanatory.

 
public String err{get;set;} //property
public void method1() {
try {
//statements
} catch(Exception e) {
err = e.getMessage();
}
}

Now you can use this property on page in this simple way

 

or in advance as

 

.message {
background-color: #ffc;
border-style: solid;
border-width: 1px;
color: #000;
padding: 6px 8px 6px 6px;
margin: 4px 20px;
}

.errorM6, .errorM4, .errorM3, .errorM2, .errorS1 {
border-color: #c00;
}

.errorM3 .msgIcon, .errorMedium {
background-image: url(/img/msg_icons/error24.png);
background-position: 0 0;
width: 24px;
height: 24px;
}

img {
border: 0;
}













error



For using advance way, you will have to upload any error image in static resource folder with name as ‘ErrorImage’.

Published by Sandeep Kumar

He is a Salesforce Certified Application Architect having 11+ years of experience in Salesforce.

Leave a Reply