You need to sign in to do that
Don't have an account?

How to execute a VF page without being redirected to the page?
I have the following VisualForce page:
<apex:page standardController="Inquery__c" recordSetVar="accvar" contentType="text/csv#filename.csv" >"First Name","Last Name","Email","Qualification"
<apex:repeat value="{!accvar}" var="a">
<apex:outputText rendered="{!NOT(a.Download__c)}">
{!a.First_Name__c}, {!a.Last_Name__c}, {!a.Email__c}, {!a.Quilification__c}
</apex:outputText>
</apex:repeat>
</apex:page>
That I call from a custom button,
Using the Using javascript:
window.location = 'apex/Download_data';
The button calls the code and it works,
But it also redirects me to the VisualForce page,
How can I just execute the code,
Without being redirected to the VF page,
Thanks
I mean redirecting using pagereference?
Could you possibly give me an example how to use PageReference?
Thanks
I tried this in the javascript window, but it didnt work,
PageReference pageRef = new PageReference('/apex/downloadonly');
PageReference secondPage = Page.downloadonly;
secondPage.setRedirect(true);
Best
This is supposed to be apex code/controller method that will invoked using a commandbutton
Oh, ok,
I thought you wanted me to use it in the javascript window instead of the window.location = 'apex/Download_data';
Let me create a controller,
And try it,
Thanks
If you are looking for a pagereference example that opens anew vf page for you, you could probably have alook at this Example For You
thanks,