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

Set tabStyle dynamically



I am creating a visualforce page, and want to set the tabStyle attribute based on Record Type.  However, when open the visualforce page with the following (where MyTabStyle is a string like 'contact', 'account', etc).





<apex:page standardController="Opportunity" extensions="myOppExtension" tabStyle="{!MyTabStyle}">



I get an error "Error: Invalid tabStyle '{!MyTabStyle}' specified. If you are trying to reference a custom Visualforce tab, you must append '__tab'".


Is setting the tabStyle this way supported?


Thank you


To use the styling associated with a custom Visualforce tab, set the attribute to the name (not label) of the tab followed by a double-underscore and the word tab. For example, to use the styling of a Visualforce tab with the name Source and a label Sources, use:
<apex:page standardController="Account" tabStyle="Source__tab">

Alternatively, you can override standard controller page styles with your own custom stylesheets and inline styles.




Thanks for the post Ivivanin - however, this isn't quite what I'm looking for.


The tabStyle is meant to be dynamic, so could be account, opportunity, contact, etc.  I'm not looking to use a static value for a custom tab.




ISVforce PartnerISVforce Partner



Any luck with this? 

seems like there is no direct solution for this ?
Sab L 10Sab L 10
This can be done using If condition and controlling controller method. Pls refer
In apex page


In controller

public string strTabName{set;}

public String getStrTabName(){ return null; } 


public String getStrTabName(){ return 'CustomCustomer__c'; }

Thanks to Jaison Hardy. Hope this helps.