0

I have Created the Visual Force Page :

<apex:page standardController = "Contact">
 <apex:form>
 <apex:pageBlock>
 <apex:pageBlockSection>
  <apex:inputfield label="Mobile #"  value="{!Contact.AccountId}" />





    <apex:pageBlockButtons location="top">
                <apex:commandButton action="{!Cancel}" value="Back"/>


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





  </apex:form>
</apex:page>

with the Account Id as Lookup Relation of all accounts ,i am unable to add the field Label for Particular Look Up Field, while saving it is showing Error: apex:pageBlock must be the direct parent of apex:pageBlockButtons How to Rectify the Error

1
  • Move the <apex:pageBlockButtons>...</apex:pageBlockButtons> content to just below the <apex:pageBlock> opening tag.
    – Keith C
    Commented Aug 17, 2016 at 12:24

1 Answer 1

3

Error message says it all. PageBlockButtons should be after the pageBlock component.

<apex:page standardController = "Contact">
    <apex:form>
        <apex:pageBlock>
            <apex:pageBlockButtons location="top">
                <apex:commandButton action="{!Cancel}" value="Back"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection>
                <apex:inputfield label="Mobile #"  value="{!Contact.AccountId}" />
                <apex:outputfield label="Mobile #"  value="{!Contact.AccountId}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .