You need to sign in to do that
Don't have an account?
Amanda Byrne- Carolina Tiger Rescue
changing CSS class in the value of an apex:commandButton
I wanted to spruce up the text on a commandButton by applying more than one CSS font class on the button label, but I get errors when I use tags inside the value parameter
Page Code:
<apex:commandButton styleClass="btnOrange" action="{!postTourQuizLink}"
value="What did you <font class='Papyrus'>Learn</font> about <font class='Papyrus'>Wildcats</font>? <font class='Afrika'>\</font>"
title="Take the post-Tour Quiz" immediate="false" />
I've also tried removing the value param and putting the label text between tags: <apex:commandButton>Label</apex.commandButton>
I tried creating a variable quizButtonTxt inside the postTourQuizLink function (on the extension ctrl) and then putting value="{!quizButtonTxt}", also not helpful.
I'm a SF Admin/code hacker-modifier, and so I don't know enough to come up with a workaround- any suggestions? Special character references?
Page Code:
<apex:commandButton styleClass="btnOrange" action="{!postTourQuizLink}"
value="What did you <font class='Papyrus'>Learn</font> about <font class='Papyrus'>Wildcats</font>? <font class='Afrika'>\</font>"
title="Take the post-Tour Quiz" immediate="false" />
I've also tried removing the value param and putting the label text between tags: <apex:commandButton>Label</apex.commandButton>
I tried creating a variable quizButtonTxt inside the postTourQuizLink function (on the extension ctrl) and then putting value="{!quizButtonTxt}", also not helpful.
I'm a SF Admin/code hacker-modifier, and so I don't know enough to come up with a workaround- any suggestions? Special character references?
You can do something like this
<a href="#" onclick="call actionFunction()" style="style to make the link a button"><span style="...your style">Learn</span><span style="..your second style">WildCats</span></a>
Then call the action function to get the comtroller method executed
<apex:actionFunction action="{!youraction}" name="yourMethod()" oncomplete="whatever necessary()" />
Thanks,
Kaustav
All Answers
You will have to use css to apply style to your button.
Go this link and check the "style" and "styleclass" attributes for commandbuttons.
you can try and do something like this
define a style class in your page
.styleButtonText{
color: red;
font-weight: bold;
}
then appky the style class to your command button
<apex:commandButton action="{!youraction}" value="Button Text" styleclass="styleButtonText" />
Either this or you can just put in your style inline - the way shown in the first line
Thanks,
Kaustav
You can try below code and let me know if this helps you.
Best Regards,
-Vivek
So the label would look like this- I would be using multple styles in the button label text
"Learn" and "Wildcats" are a different CSS style.
You can do something like this
<a href="#" onclick="call actionFunction()" style="style to make the link a button"><span style="...your style">Learn</span><span style="..your second style">WildCats</span></a>
Then call the action function to get the comtroller method executed
<apex:actionFunction action="{!youraction}" name="yourMethod()" oncomplete="whatever necessary()" />
Thanks,
Kaustav
Page Code:
<apex:outputText value="{!selectedAttendeeButtonId}"/>
<apex:selectList styleClass="detail" size="1" id="preTourQuizAttendeeOptions" value="{!selectedAttendeeId}" onchange="call postSelectedAttendee()">
<apex:SelectOptions value="{!preTourQuizAttendeeValues}" >
</apex:SelectOptions>
<apex:param name="Type" value="preTourQuizAttendee.Id" assignTo="{!selectedAttendeeId}"/>
</apex:selectList>
<a id="quizButton" href="https://www.getfeedback.com/r/{!surveyid}?CnP_PaaS_EVT__Event_attendee_session__c={!selectedAttendeeButtonId}">
What did you <span class="Papyrus">Learn</span> about <span class="Papyrus">Wildcats</span>?
</a>
public String selectedAttendeeButtonId {get; set;}
public DTCI_Remote_Methods_AB_Ctrl (ApexPages.StandardSetController controller) {
selectedAttendeeButtonId = '';
}
public String postTourQuizFxn(){
selectedAttendeeButtonId = selectedAttendeeId;
return selectedAttendeeButtonId;
}
<apex:outputText value="{!selectedAttendeeButtonId}"/>
<apex:selectList styleClass="detail" size="1" id="preTourQuizAttendeeOptions" value="{!selectedAttendeeId}" onchange="postSelectedAttendee()">
<apex:SelectOptions value="{!preTourQuizAttendeeValues}" >
</apex:SelectOptions>
<apex:param name="Type" value="preTourQuizAttendee.Id" assignTo="{!selectedAttendeeId}"/>
</apex:selectList>
<apex:outputLink id="quizButton" value="https://www.getfeedback.com/r/{!surveyid}?CnP_PaaS_EVT__Event_attendee_session__c={!selectedAttendeeButtonId}">
What did you <span class="Papyrus">Learn</span> about <span class="Papyrus">Wildcats</span>?
</apex:outputLink>
Ctrl:
public String selectedAttendeeId {get; set;}
public String selectedAttendeeButtonId {get; set;}
public String surveyId {get; set;}
public DTCI_Remote_Methods_AB_Ctrl (ApexPages.StandardSetController controller) {
selectedAttendeeButtonId = '';
}
public void postTourQuizFxn(){
selectedAttendeeButtonId = selectedAttendeeId;
//return selectedAttendeeButtonId;
surveyId = "whatever value you need";
} // no need to return here the variables are public and has the getter so they are available in the page
Also it would be great if you can give more code and a clear description about what exactly you want to implement.
Let me know if you need more help on this.
Thanks,
Kaustav
But thanks again!