You need to sign in to do that
Don't have an account?
Nitish Kulkarni
Unknown property 'insertewsclass.resource' error using custom controller in visualforce page
I am getting unknown property error while using custom controller.I am using Developer console.please help
VisualForce code
Apex code
VisualForce code
<apex:page showHeader="false" controller="insertewsclass"> <style> td{font-size:20px;color:blue} .st{font-size:25px;color:red} </style> <apex:form > <apex:image value="{!resource.logo}" width="220" height="100"/> <apex:pageBlock tabStyle="Employment_Website__c"> <apex:outputText value="{!msg}" style="st"/><br/><br/> <table boder="0" width="70%" height="70"> <tr> <td>EWS Name</td> <td><apex:inputText value="{!name}"/></td> </tr> <tr> <td>Price per post</td> <td><apex:inputText value="{!pp}"/></td> </tr> <tr> <td>Maximum budget</td> <td><apex:inputText value="{!mb}"/></td> </tr> <tr> <td>URL</td> <td><apex:inputText value="{!url}"/></td> </tr> <tr> <td></td> <td><apex:commandButton value="Insert" action="insert_rec" style="font-size:15px"/> <input type="reset" style="font-size:15px"/></td> </tr> </table> </apex:pageBlock> </apex:form> </apex:page>
Apex code
public class insertewsclass { public string name{get;set;} public double pp{get;set;} public double mb{get;set;} public string url{get;set;} public string msg; public void insert_rec() { integer namecount = [select count() from Employment_Website__c where Name = :name]; integer urlcount = [select count() from Employment_Website__c where Website_address__c = :url]; if(namecount > 0 || urlcount > 0) { msg = 'Record Insertion Failed'; } else { Employment_Website__c ob = new Employment_Website__c(); ob.Name = name; ob.Price_per_post__c = pp; ob.Maximum_budget__c = mb; ob.Website_address__c = url; msg = 'Record Inserted Successfully'; } } public string getmsg() { return(msg); } }
If you are static resource for image in vf page then you have to use this syntax
{!$Resource.logo}. You have missed $ sign.
Thanks
All Answers
The problem is {!resource.logo} that is not resolved.
<apex:image value="{
!resource.logo}" width="220" height="100"/>You can try this at first:
<apex:image value="/img/logo.png" width="220" height="100" />
But you need to identify clearly what is this logo because there are many syntaxes for resolving the images:
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_image.htm
If you are static resource for image in vf page then you have to use this syntax
{!$Resource.logo}. You have missed $ sign.
Thanks
Try the below change in the <apex:Image> Tag:
I think you are missing $
<apex:image url="{!$Resource.logo}" width="220" height="100"/>
or
<apex:image i value="{!$Resource.logo}" width="220" height="100" />
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_resources_reference.htm
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_image.htm
Can you please Let me know if it helps or not!!!
If it helps don't forget to mark this as a best answer!!!
Thanks,
Raj
Thanks Alian , Jyoti and Maharaja.
I missed $ sign thatswhy it was not working.