I have a custom controller with a variable I'm assigning a value to and then trying to display that value on a VF page but the value is not displaying. It's a very simple case – what am I missing?
Controller:
public with sharing class myController {
public string pid {get;set;}
public void myController() {
pid = 'hard-coded value in controller';
}
}
VF page:
<apex:page controller="myController"
showHeader="false">
<apex:PageBlock title="My title">
PID: {!pid}
</apex:PageBlock>
</apex:page>
Best Answer
You need to specify controller in apex:page
Refer Creating a Custom Controller Class