[SalesForce] Passing URL parameters from VF page to custom controller

How can I take a URL parameter and pass it to a custom controller method? For example, I have a button from a case that goes to VF page with its ID in the url. (ex – https://visual.force.com/apex/CustomSearch?caseID=18238345iu3) I want to then press a button on the VF page that will execute a method from my custom controller and use the case ID parameter found in the URL.

Thanks.

Best Answer

When passing parameters in a URL, you can grab the parameter values in your Visualforce Controller by using:

String thecaseID = System.currentPageReference().getParameters().get('caseID');