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

  • Move the <apex:pageBlockButtons>...</apex:pageBlockButtons> content to just below the <apex:pageBlock> opening tag. – Keith C Aug 17 '16 at 12:24
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>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.