function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sfdcvirajsfdcviraj 

How to hide a blocksection onload of a VF Page?

In VF Page, On click of a button, I need to show a pageblock section with id="wanttohidethispageblock", which has table content in it. 

By default, the pageblocksection appears due to obvious reason its not hidden. 

How can I hide this pageblock section with id="wanttohidethispageblock" on VF page onload. 

Thanks.

 
Best Answer chosen by sfdcviraj
Arunkumar RArunkumar R
Hope you are using controller. Let's take a below example. Use rendered attribute.

Controller:
 
public class PBController
{
    public boolean hideSec{get; set;}

    public PBController()
    {
         hideSec = false;
    }
   
    public void doProcess()
    {
       hideSec = true;
    }

}

Page:
 
<apex:page controller="PBController">

<apex:pageBlock>
<apex:pageBlockSection rendered = "{!hideSec}">

</apex:pageBlockSection>
</apex:pageBlock>

</apex:page>

All Answers

Arunkumar RArunkumar R
Hope you are using controller. Let's take a below example. Use rendered attribute.

Controller:
 
public class PBController
{
    public boolean hideSec{get; set;}

    public PBController()
    {
         hideSec = false;
    }
   
    public void doProcess()
    {
       hideSec = true;
    }

}

Page:
 
<apex:page controller="PBController">

<apex:pageBlock>
<apex:pageBlockSection rendered = "{!hideSec}">

</apex:pageBlockSection>
</apex:pageBlock>

</apex:page>
This was selected as the best answer
sfdcvirajsfdcviraj
@Arun - Thanks!

What I did apart from this working peice of code is set the hideSec = true on click of the button which I wanted. And voila! Its working.

Thanks again.