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

Conditional display of html tag on a visualforce page



I have a html tag for a checkbox field that I display on visualforce page. The field will be visible only to certain people, so my requirement is I want this html tag to be visible on the visualforce page only to the people who have access to this checkbox field. How do I achieve this? Does anybody have any suggestions or some sample code that I could use for my page?






Kamatchi Devi SargunanathanKamatchi Devi Sargunanathan



Yeah you can achieve this by querying the particular profile user in the Controller and rendering the field based on the condition.


For example,


public class demoCon{

   public List<User> ulist{get;set;}

   public ID userID{get;set;}


    public demoCon(){

          Profile p = [select id,name from profile where name =: '<Your profile name>' limit 1];

          ulist = [select id,name,profileID from user where profileID =: limit 1];

          if(ulist.size() > 0){

              if(user u1 : ulist){

                   userID =;






VF page:

<apex:page standardController="Account" class = "democon">



            <apex:inputfield value="{!Account.checkboxField__c}" rendered="{!Account.OwnerId == userID}"/>





In the above example, controller itself we are querying the condition for the profiles you need to show the field. In the Vf page we are rendering the field based on the owner equals to that id.



Hope so this helps you...!


Please mark this answer a Solution and please give kudos by clicking on the star icon, if you found this answer as helpful.


Thanks Kamatchi for your suggestion! I would to conditionally display a html tag on a visualforce page. As in if a field is visible to the user, then display the html tag.


Kamatchi Devi SargunanathanKamatchi Devi Sargunanathan

Sorry, its not clear can you please explain in detail?

Say with an example.