You need to sign in to do that
Don't have an account?
Set iframe source from VF page
Hi,
We need to set the source of an iframe using a text field on a VF page on page load. The text field on the parent page contains the name of another VF page to load in the iframe.
This works (full URL):
<iframe width="100%" height="500" frameborder="0" scrolling="true" marginheight="0" marginwidth="0" src="https://c.na7.visual.force.com/apex/aaobarchartplain" ></iframe>
This does not (where Dashboard_Report__c is the custom object, and Page_Name__c is the name of the field containing the name of the VF page we want to load in the iframe; page name example is rmbarchart):
<iframe width="100%" height="500" frameborder="0" scrolling="true" marginheight="0" marginwidth="0" src="Dashboard_Report__c. Page_Name__c"></iframe>
On the latter, an error is thrown; “The name 'c.Page_Name' can only contain alphanumeric characters, must begin with a letter, and must be unique.”
This also throws an error:
<iframe width="100%" height="500" frameborder="0" scrolling="true" marginheight="0" marginwidth="0" src="Page_Name">
Error; “Page Page_Name does not exist”
Any help or suggestions is appreciated.
You need to use an expression to get the value of that field substituted....
src="{!Dashboard_Report__c. Page_Name__c}"
(Or it probably needs to be
src="Dashboard_Report__r. Page_Name__c" to follow the relationship
)
All Answers
HI
You should write something like this.
In Class:-
public string myPageName{get;set;}
public yourclassname(){
myPageName = Dashboard_Report__c. Page_Name__c;
}
On Apex page:-
<iframe width="100%" height="500" frameborder="0" scrolling="true" marginheight="0" marginwidth="0" src="{!myPageName}"></iframe>
Thanks,
Ravi
You need to use an expression to get the value of that field substituted....
src="{!Dashboard_Report__c. Page_Name__c}"
(Or it probably needs to be
src="Dashboard_Report__r. Page_Name__c" to follow the relationship
)
Thank you aballard! That did it!
You need to use an expression to get the value of that field substituted....
src="{!Dashboard_Report__c. Page_Name__c}"
Extremely grateful for your help!
(Thank you too Ravi; I can use your suggestion elsewhere!)